Package org.apache.ignite.internal.util
Class GridQueue<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- org.apache.ignite.internal.util.GridQueue<E>
-
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Queue<E>
public class GridQueue<E> extends AbstractCollection<E> implements Queue<E>
Queue which supports addition at tail and removing at head. This queue also exposes its internal linked list nodes and allows for constant time removal from the middle of the queue.This queue is not thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGridQueue.Node<E>Node for internal linked list.
-
Constructor Summary
Constructors Constructor Description GridQueue()Creates empty queue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E e)Eelement()Iterator<E>iterator()booleanoffer(E e)GridQueue.Node<E>offerx(E e)Same asoffer(Object), but returns created node.Epeek()GridQueue.Node<E>peekx()Epoll()Polls element from head of the queue.Eremove()booleanremove(Object o)intsize()Gets queue size.voidunlink(GridQueue.Node<E> n)Unlinks node from the queue.-
Methods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
-
-
-
Method Detail
-
add
public boolean add(E e)
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceQueue<E>- Overrides:
addin classAbstractCollection<E>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<E>- Overrides:
removein classAbstractCollection<E>
-
offerx
public GridQueue.Node<E> offerx(E e)
Same asoffer(Object), but returns created node.- Parameters:
e- Element to add.- Returns:
- New node.
-
poll
@Nullable public E poll()
Polls element from head of the queue.
-
peekx
public GridQueue.Node<E> peekx()
- Returns:
- Peeks at first node in the queue.
-
unlink
public void unlink(GridQueue.Node<E> n)
Unlinks node from the queue.- Parameters:
n- Node to unlink.
-
size
public int size()
Gets queue size.- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein classAbstractCollection<E>- Returns:
- Queue size.
-
-