Top Constructors Methods
io.vavr.collection

pack-priv abstract Class AbstractQueue<T, Q extends AbstractQueue<T, Q>>

extends Object
implements Traversable<T>
Class Inheritance
All Implemented Interfaces
io.vavr.collection.Traversable, io.vavr.Value, java.lang.Iterable, io.vavr.collection.Foldable
Known Direct Subclasses
io.vavr.collection.PriorityQueue, io.vavr.collection.Queue
Imports
io.vavr.Tuple, .Tuple2, io.vavr.control.Option, java.util.NoSuchElementException, .Objects, java.util.function.Consumer, .Predicate

Author
Pap Lőrinc, Daniel Dietrich

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Tuple2<T, Q>

Returns:

a tuple containing the first element and the remaining elements of this Queue
dequeue
()

Removes an element from this Queue.

public Option<Tuple2<T, Q>>

Returns:

None if this Queue is empty, otherwise Some Tuple containing the first element and the remaining elements of this Queue
dequeueOption
()

Removes an element from this Queue.

public Q
dropUntil(Predicate<? super T>
A condition tested subsequently for this elements.
predicate
)

Implements io.vavr.collection.Traversable.dropUntil.

Drops elements until the predicate holds for the current element.

public abstract Q
dropWhile(Predicate<? super T>
A condition tested subsequently for this elements.
predicate
)

Redeclares io.vavr.collection.Traversable.dropWhile.

Drops elements while the predicate holds for the current element.

public abstract Q

Returns:

a new Queue instance, containing the new element
enqueue
(T
The new element
element
)

Enqueues a new element.

public Q

Returns:

a new Queue instance, containing the new elements
enqueue
(T...
Elements, may be empty
elements
)

Enqueues the given elements.

public abstract Q

Returns:

a new Queue instance, containing the new elements
enqueueAll
(Iterable<? extends T>
An Iterable of elements, may be empty
elements
)

Enqueues the given elements.

public abstract Q

Returns:

a new instance containing all elements except the last.
init
()

Redeclares io.vavr.collection.Traversable.init.

Dual of tail(), returning all elements except the last.

public Option<Q>

Returns:

Some(Q) or None if this is empty.
initOption
()

Overrides default io.vavr.collection.Traversable.initOption.

Dual of tailOption(), returning all elements except the last as Option.

public T

Returns:

the first element
peek
()

Returns the first element without modifying it.

public Q
peek(Consumer<? super T>
The action that will be performed on the element(s).
action
)

Implements io.vavr.collection.Traversable.peek.

Performs the given action on the first element if this is an eager implementation.

public Option<T>

Returns:

None if this Queue is empty, otherwise a Some containing the first element
peekOption
()

Returns the first element without modifying the Queue.

public Q
reject(Predicate<? super T>
A predicate
predicate
)

Overrides default io.vavr.collection.Traversable.reject.

Returns a new traversable consisting of all elements which do not satisfy the given predicate.

public Q
removeAll(Iterable<? extends T> elements)

public Q
removeAll(Predicate<? super T> predicate)
Deprecated

public Q
retainAll(Iterable<? extends T>
Elements to be kept.
elements
)

Implements io.vavr.collection.Traversable.retainAll.

Keeps all occurrences of the given elements from this.

public abstract Q

Returns:

A new instance of Traversable containing all elements except the first.
tail
()

Redeclares io.vavr.collection.Traversable.tail.

Drops the first element of a non-empty Traversable.

public Option<Q>
tailOption()

Implements io.vavr.collection.Traversable.tailOption.

Drops the first element of a non-empty Traversable and returns an Option.

public abstract Q
takeUntil(Predicate<? super T>
A condition tested subsequently for this elements.
predicate
)

Redeclares io.vavr.collection.Traversable.takeUntil.

Takes elements until the predicate holds for the current element.

public Q
takeWhile(Predicate<? super T>
A condition tested subsequently for the contained elements.
predicate
)

Implements io.vavr.collection.Traversable.takeWhile.

Takes elements while the predicate holds for the current element.

public String
toString()

Overrides java.lang.Object.toString.

Implements io.vavr.Value.toString.

Clarifies that values have a proper toString() method implemented.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Constructor Detail

AbstractQueueback to summary
pack-priv AbstractQueue()

Method Detail

dequeueback to summary
public Tuple2<T, Q> dequeue()

Removes an element from this Queue.

Returns:Tuple2<T, Q>

a tuple containing the first element and the remaining elements of this Queue

Exceptions
NoSuchElementException:
if this Queue is empty
dequeueOptionback to summary
public Option<Tuple2<T, Q>> dequeueOption()

Removes an element from this Queue.

Returns:Option<Tuple2<T, Q>>

None if this Queue is empty, otherwise Some Tuple containing the first element and the remaining elements of this Queue

dropUntilback to summary
public Q dropUntil(Predicate<? super T> predicate)

Implements io.vavr.collection.Traversable.dropUntil.

Doc from io.vavr.collection.Traversable.dropUntil.

Drops elements until the predicate holds for the current element.

Parameters
predicate:Predicate<? super T>

A condition tested subsequently for this elements.

Returns:Q

a new instance consisting of all elements starting from the first one which does satisfy the given predicate.

Annotations
@Override
dropWhileback to summary
public abstract Q dropWhile(Predicate<? super T> predicate)

Redeclares io.vavr.collection.Traversable.dropWhile.

Doc from io.vavr.collection.Traversable.dropWhile.

Drops elements while the predicate holds for the current element.

Note

This is essentially the same as dropUntil(predicate.negate()). It is intended to be used with method references, which cannot be negated directly.

Parameters
predicate:Predicate<? super T>

A condition tested subsequently for this elements.

Returns:Q

a new instance consisting of all elements starting from the first one which does not satisfy the given predicate.

Annotations
@Override
enqueueback to summary
public abstract Q enqueue(T element)

Enqueues a new element.

Parameters
element:T

The new element

Returns:Q

a new Queue instance, containing the new element

enqueueback to summary
public Q enqueue(T... elements)

Enqueues the given elements. A queue has FIFO order, i.e. the first of the given elements is the first which will be retrieved.

Parameters
elements:T[]

Elements, may be empty

Returns:Q

a new Queue instance, containing the new elements

Annotations
@SuppressWarnings:unchecked
Exceptions
NullPointerException:
if elements is null
enqueueAllback to summary
public abstract Q enqueueAll(Iterable<? extends T> elements)

Enqueues the given elements. A queue has FIFO order, i.e. the first of the given elements is the first which will be retrieved.

Parameters
elements:Iterable<? extends T>

An Iterable of elements, may be empty

Returns:Q

a new Queue instance, containing the new elements

Exceptions
NullPointerException:
if elements is null
initback to summary
public abstract Q init()

Redeclares io.vavr.collection.Traversable.init.

Dual of tail(), returning all elements except the last.

Returns:Q

a new instance containing all elements except the last.

Annotations
@Override
Exceptions
UnsupportedOperationException:
if this is empty
initOptionback to summary
public Option<Q> initOption()

Overrides default io.vavr.collection.Traversable.initOption.

Dual of tailOption(), returning all elements except the last as Option.

Returns:Option<Q>

Some(Q) or None if this is empty.

Annotations
@Override
peekback to summary
public T peek()

Returns the first element without modifying it.

Returns:T

the first element

Exceptions
NoSuchElementException:
if this Queue is empty
peekback to summary
public Q peek(Consumer<? super T> action)

Implements io.vavr.collection.Traversable.peek.

Doc from io.vavr.Value.peek.

Performs the given action on the first element if this is an eager implementation. Performs the given action on all elements (the first immediately, successive deferred), if this is a lazy implementation.

Parameters
action:Consumer<? super T>

The action that will be performed on the element(s).

Returns:Q

this instance

Annotations
@SuppressWarnings:unchecked
@Override
peekOptionback to summary
public Option<T> peekOption()

Returns the first element without modifying the Queue.

Returns:Option<T>

None if this Queue is empty, otherwise a Some containing the first element

rejectback to summary
public Q reject(Predicate<? super T> predicate)

Overrides default io.vavr.collection.Traversable.reject.

Doc from io.vavr.collection.Traversable.reject.

Returns a new traversable consisting of all elements which do not satisfy the given predicate.

The default implementation is equivalent to

filter(predicate.negate()
Parameters
predicate:Predicate<? super T>

A predicate

Returns:Q

a new traversable

Annotations
@SuppressWarnings:unchecked
@Override
removeAllback to summary
public Q removeAll(Iterable<? extends T> elements)
Annotations
@SuppressWarnings:unchecked
removeAllback to summary
public Q removeAll(Predicate<? super T> predicate)

Deprecated

Annotations
@Deprecated
retainAllback to summary
public Q retainAll(Iterable<? extends T> elements)

Implements io.vavr.collection.Traversable.retainAll.

Doc from io.vavr.collection.Traversable.retainAll.

Keeps all occurrences of the given elements from this.

Parameters
elements:Iterable<? extends T>

Elements to be kept.

Returns:Q

a Traversable containing all occurrences of the given elements.

Annotations
@Override
@SuppressWarnings:unchecked
tailback to summary
public abstract Q tail()

Redeclares io.vavr.collection.Traversable.tail.

Drops the first element of a non-empty Traversable.

Returns:Q

A new instance of Traversable containing all elements except the first.

Annotations
@Override
Exceptions
UnsupportedOperationException:
if this is empty
tailOptionback to summary
public Option<Q> tailOption()

Implements io.vavr.collection.Traversable.tailOption.

Doc from io.vavr.collection.Traversable.tailOption.

Drops the first element of a non-empty Traversable and returns an Option.

Returns:Option<Q>

Some(traversable) or None if this is empty.

Annotations
@Override
takeUntilback to summary
public abstract Q takeUntil(Predicate<? super T> predicate)

Redeclares io.vavr.collection.Traversable.takeUntil.

Doc from io.vavr.collection.Traversable.takeUntil.

Takes elements until the predicate holds for the current element.

Note

This is essentially the same as takeWhile(predicate.negate()). It is intended to be used with method references, which cannot be negated directly.

Parameters
predicate:Predicate<? super T>

A condition tested subsequently for this elements.

Returns:Q

a new instance consisting of all elements before the first one which does satisfy the given predicate.

Annotations
@Override
takeWhileback to summary
public Q takeWhile(Predicate<? super T> predicate)

Implements io.vavr.collection.Traversable.takeWhile.

Doc from io.vavr.collection.Traversable.takeWhile.

Takes elements while the predicate holds for the current element.

Parameters
predicate:Predicate<? super T>

A condition tested subsequently for the contained elements.

Returns:Q

a new instance consisting of all elements before the first one which does not satisfy the given predicate.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements io.vavr.Value.toString.

Doc from io.vavr.Value.toString.

Clarifies that values have a proper toString() method implemented.

See Object.toString().

Returns:String

A String representation of this object

Annotations
@Override