Package civitas.celestis.util.grid
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
The base class for all grids, including primitive specialized grids.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncollect()Returns a collection containing every element within this grid.intcolumns()Returns the number of columns (the width) of this grid.static <T> booleanChecks for equality between two instances ofgrids.voidforEach(TriConsumer<Integer, Integer, ? super E> a) Executes the provided action for each element of this grid.voidExecutes the provided action for each element of this grid.iterator()Returns an iterator of every element of this grid.introws()Returns the number of rows (the height) of this grid.set()Returns a set containing every element of this grid.intsize()Returns the size (the geometric area) of this grid.Methods inherited from interface java.lang.Iterable
spliterator
-
Method Details
-
equals
Checks for equality between two instances ofgrids. This will returntrueif the dimensions, order of elements, and the element's values are all equal. In other words, this returnstrueif 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 compareg2- The second grid to compare- Returns:
trueif 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
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
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
Returns an iterator of every element of this grid. -
forEach
Executes the provided action for each element of this grid. The order of execution is not guaranteed to be consistent. -
forEach
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
-