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
`static class` `GridQueue.Node<E>` Node for internal linked list.

### Constructor Summary

Constructors
Constructor and Description
`GridQueue()` Creates empty queue.

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `add(E e)`
`E` `element()`
`Iterator<E>` `iterator()`
`boolean` `offer(E e)`
`GridQueue.Node<E>` `offerx(E e)` Same as `offer(Object)`, but returns created node.
`E` `peek()`
`GridQueue.Node<E>` `peekx()`
`E` `poll()` Polls element from head of the queue.
`E` `remove()`
`boolean` `remove(Object o)`
`int` `size()` Gets queue size.
`void` `unlink(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`

### Methods inherited from interface java.lang.Iterable

`forEach`

### Constructor Detail

#### GridQueue

    public GridQueue()

Creates empty queue.

### Method Detail

#### add

    public boolean add(E e)

Specified by:
  `add` in interface `Collection<E>`
Specified by:
  `add` in interface `Queue<E>`
Overrides:
  `add` in class `AbstractCollection<E>`

#### remove

    public boolean remove(Object o)

Specified by:
  `remove` in interface `Collection<E>`
Overrides:
  `remove` in class `AbstractCollection<E>`

#### offer

    public boolean offer(E e)

Specified by:
  `offer` in interface `Queue<E>`

#### offerx

    public GridQueue.Node<E> offerx(E e)

Same as `offer(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.

Specified by:
  `poll` in interface `Queue<E>`
Returns:
  Polled element.

#### element

    public E element()

Specified by:
  `element` in interface `Queue<E>`

#### remove

    public E remove()

Specified by:
  `remove` in interface `Queue<E>`

#### peek

    @Nullable
    public E peek()

Specified by:
  `peek` in interface `Queue<E>`

#### 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:
  `size` in interface `Collection<E>`
Specified by:
  `size` in class `AbstractCollection<E>`
Returns:
  Queue size.

#### iterator

    public Iterator<E> iterator()

Specified by:
  `iterator` in interface `Iterable<E>`
Specified by:
  `iterator` in interface `Collection<E>`
Specified by:
  `iterator` in class `AbstractCollection<E>`

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.6.0
Release Date | : July 10 2018