Class SparseQueueGridIndex<T>
java.lang.Object
net.mtrop.doom.struct.map.SparseGridIndex<Queue<T>>
net.mtrop.doom.struct.map.SparseQueueGridIndex<T>
- Type Parameters:
T- the value type.
- All Implemented Interfaces:
Iterable<Map.Entry<SparseGridIndex.Pair, Queue<T>>>,Sizable
A sparse grid index that contains lists of objects.
Be advised that the
SparseGridIndex.get(int, int) method may return null if no objects
are queued at that particular spot.- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested classes/interfaces inherited from class net.mtrop.doom.struct.map.SparseGridIndex
SparseGridIndex.Pair -
Field Summary
Fields inherited from class net.mtrop.doom.struct.map.SparseGridIndex
data -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new sparse queue grid of an unspecified width and height. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears everything from the grid.dequeue(int x, int y) Dequeues an object at a particular grid coordinate.voidEnqueues an object at a particular grid coordinate.getQueue(int x, int y) Returns a queue for a set of coordinates.booleanisEmpty()Returns if this object contains no objects.iterator(int x, int y) Returns an iterator for a queue at a particular grid coordinate.booleanDequeues an object at a particular grid coordinate.voidSets an object at a particular part of the grid.intsize()Methods inherited from class net.mtrop.doom.struct.map.SparseGridIndex
get, iterator, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
SparseQueueGridIndex
public SparseQueueGridIndex()Creates a new sparse queue grid of an unspecified width and height.- Throws:
IllegalArgumentException- if capacity is negative or ratio is 0 or less.
-
-
Method Details
-
enqueue
Enqueues an object at a particular grid coordinate.- Parameters:
x- the x-coordinate.y- the y-coordinate.object- the object to add.
-
dequeue
Dequeues an object at a particular grid coordinate.- Parameters:
x- the x-coordinate.y- the y-coordinate.- Returns:
- the first object added at the set of coordinates, null if no objects enqueued.
-
remove
Dequeues an object at a particular grid coordinate.- Parameters:
x- the x-coordinate.y- the y-coordinate.object- the object to remove.- Returns:
- the first object added at the set of coordinates, null if no objects enqueued.
-
iterator
-
getQueue
-
set
Description copied from class:SparseGridIndexSets an object at a particular part of the grid.- Overrides:
setin classSparseGridIndex<Queue<T>>- Parameters:
x- the grid position x to set info.y- the grid position y to set info.queue- the object to set. Can be null.
-
clear
public void clear()Description copied from class:SparseGridIndexClears everything from the grid.- Overrides:
clearin classSparseGridIndex<Queue<T>>
-
size
-
isEmpty
public boolean isEmpty()Description copied from interface:SizableReturns if this object contains no objects. The general policy of this method is that this returns true if and only ifSizable.size()returns 0.
-