Interface BaseGrid<E>

Type Parameters:
E - The type of element this grid should hold
All Superinterfaces:
Iterable<E>, Serializable
All Known Subinterfaces:
DoubleGrid, DynamicGrid<E>, FloatGrid, Grid<E>, IntGrid, LongGrid
All Known Implementing Classes:
ArrayGrid, AtomicGrid, DoubleArrayGrid, FloatArrayGrid, HashGrid, IntArrayGrid, LongArrayGrid, Matrix, SyncGrid

public interface BaseGrid<E> extends Iterable<E>, Serializable
The base class for all grids, including primitive specialized grids.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a collection containing every element within this grid.
    int
    Returns the number of columns (the width) of this grid.
    static <T> boolean
    equals(BaseGrid<T> g1, BaseGrid<?> g2)
    Checks for equality between two instances of grids.
    void
    Executes the provided action for each element of this grid.
    void
    forEach(Consumer<? super E> a)
    Executes the provided action for each element of this grid.
    Returns an iterator of every element of this grid.
    int
    Returns the number of rows (the height) of this grid.
    set()
    Returns a set containing every element of this grid.
    int
    Returns the size (the geometric area) of this grid.

    Methods inherited from interface java.lang.Iterable

    spliterator
  • Method Details

    • equals

      static <T> boolean equals(@Nullable BaseGrid<T> g1, @Nullable BaseGrid<?> g2)
      Checks for equality between two instances of grids. This will return true if the dimensions, order of elements, and the element's values are all equal. In other words, this returns true if all corresponding element pairs are equal.
      Type Parameters:
      T - The element of the first grid (used for copying the grid)
      Parameters:
      g1 - The first grid to compare
      g2 - The second grid to compare
      Returns:
      true if the grids are considered equal according to the criteria mentioned above
    • rows

      int rows()
      Returns the number of rows (the height) of this grid.
      Returns:
      The number of rows this grid has
    • columns

      int columns()
      Returns the number of columns (the width) of this grid.
      Returns:
      The number of columns this grid has
    • size

      int size()
      Returns the size (the geometric area) of this grid. In other words, this return the maximum capacity of this grid.
      Returns:
      The number of element this gird can potentially hold
    • collect

      @Nonnull Collection<E> collect()
      Returns a collection containing every element within this grid. The size of the collection is not guaranteed to be equal to the size of this grid, and the order is not guaranteed to be consistent, if there even is one.
      Returns:
      The collection representation of this grid
      See Also:
    • set

      @Nonnull Set<E> set()
      Returns a set containing every element of this grid. Due to the nature of sets, every duplicate element will be counted as one element. This property can be useful for certain applications.
      Returns:
      The set representation of this grid
      See Also:
    • iterator

      @Nonnull Iterator<E> iterator()
      Returns an iterator of every element of this grid.
      Specified by:
      iterator in interface Iterable<E>
      Returns:
      An iterator of every element of this grid
    • forEach

      void forEach(@Nonnull Consumer<? super E> a)
      Executes the provided action for each element of this grid. The order of execution is not guaranteed to be consistent.
      Specified by:
      forEach in interface Iterable<E>
      Parameters:
      a - The action to be performed for each element
    • forEach

      void forEach(@Nonnull TriConsumer<Integer,Integer,? super E> a)
      Executes the provided action for each element of this grid. The row and column indices are provided as the first and second parameter of the function respectively, and the current element is provided as the third parameter of the function. The order of execution is not guaranteed to be consistent.
      Parameters:
      a - The action to be performed for each element