Package io.vavr.collection
Class AbstractQueue<T,Q extends AbstractQueue<T,Q>>
java.lang.Object
io.vavr.collection.AbstractQueue<T,Q>
- All Implemented Interfaces:
Foldable<T>
,Traversable<T>
,Value<T>
,Iterable<T>
- Direct Known Subclasses:
PriorityQueue
,Queue
abstract class AbstractQueue<T,Q extends AbstractQueue<T,Q>>
extends Object
implements Traversable<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondequeue()
Removes an element from this Queue.Removes an element from this Queue.Drops elements until the predicate holds for the current element.abstract Q
Drops elements while the predicate holds for the current element.abstract Q
Enqueues a new element.Enqueues the given elements.abstract Q
enqueueAll
(Iterable<? extends T> elements) Enqueues the given elements.abstract Q
init()
Dual of tail(), returning all elements except the last.Dual of tailOption(), returning all elements except the last asOption
.peek()
Returns the first element without modifying it.Performs the givenaction
on the first element if this is an eager implementation.Returns the first element without modifying the Queue.Returns a new traversable consisting of all elements which do not satisfy the given predicate.Deprecated.Keeps all occurrences of the given elements from this.abstract Q
tail()
Drops the first element of a non-empty Traversable.Drops the first element of a non-empty Traversable and returns anOption
.abstract Q
Takes elements until the predicate holds for the current element.Takes elements while the predicate holds for the current element.toString()
Clarifies that values have a proper toString() method implemented.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.vavr.collection.Foldable
fold, reduce, reduceOption
Methods inherited from interface io.vavr.collection.Traversable
arrangeBy, average, collect, containsAll, count, distinct, distinctBy, distinctBy, drop, dropRight, equals, existsUnique, filter, find, findLast, flatMap, foldLeft, foldRight, forEachWithIndex, get, groupBy, grouped, hasDefiniteSize, hashCode, head, headOption, isDistinct, isEmpty, isOrdered, isSequential, isSingleValued, isTraversableAgain, iterator, last, lastOption, length, map, max, maxBy, maxBy, min, minBy, minBy, mkCharSeq, mkCharSeq, mkCharSeq, mkString, mkString, mkString, nonEmpty, orElse, orElse, partition, product, reduceLeft, reduceLeftOption, reduceRight, reduceRightOption, replace, replaceAll, scan, scanLeft, scanRight, single, singleOption, size, slideBy, sliding, sliding, span, spliterator, sum, take, takeRight, unzip, unzip3, zip, zipAll, zipWith, zipWithIndex, zipWithIndex
Methods inherited from interface io.vavr.Value
collect, collect, contains, corresponds, eq, exists, forAll, forEach, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, getOrNull, isAsync, isLazy, out, out, stderr, stdout, stringPrefix, toArray, toCharSeq, toCompletableFuture, toEither, toEither, toInvalid, toInvalid, toJavaArray, toJavaArray, toJavaArray, toJavaCollection, toJavaList, toJavaList, toJavaMap, toJavaMap, toJavaMap, toJavaOptional, toJavaParallelStream, toJavaSet, toJavaSet, toJavaStream, toLeft, toLeft, toLinkedMap, toLinkedMap, toLinkedSet, toList, toMap, toMap, toOption, toPriorityQueue, toPriorityQueue, toQueue, toRight, toRight, toSet, toSortedMap, toSortedMap, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toStream, toTree, toTree, toTry, toTry, toValid, toValid, toValidation, toValidation, toVector
-
Constructor Details
-
AbstractQueue
AbstractQueue()
-
-
Method Details
-
dequeue
Removes an element from this Queue.- Returns:
- a tuple containing the first element and the remaining elements of this Queue
- Throws:
NoSuchElementException
- if this Queue is empty
-
dequeueOption
Removes an element from this Queue.- Returns:
None
if this Queue is empty, otherwiseSome
Tuple
containing the first element and the remaining elements of this Queue
-
enqueue
Enqueues a new element.- Parameters:
element
- The new element- Returns:
- a new
Queue
instance, containing the new element
-
enqueue
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
- Elements, may be empty- Returns:
- a new
Queue
instance, containing the new elements - Throws:
NullPointerException
- if elements is null
-
enqueueAll
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
- An Iterable of elements, may be empty- Returns:
- a new
Queue
instance, containing the new elements - Throws:
NullPointerException
- if elements is null
-
peek
Returns the first element without modifying it.- Returns:
- the first element
- Throws:
NoSuchElementException
- if this Queue is empty
-
peekOption
Returns the first element without modifying the Queue.- Returns:
None
if this Queue is empty, otherwise aSome
containing the first element
-
dropUntil
Description copied from interface:Traversable
Drops elements until the predicate holds for the current element.- Specified by:
dropUntil
in interfaceTraversable<T>
- Parameters:
predicate
- A condition tested subsequently for this elements.- Returns:
- a new instance consisting of all elements starting from the first one which does satisfy the given predicate.
-
dropWhile
Description copied from interface:Traversable
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.- Specified by:
dropWhile
in interfaceTraversable<T>
- Parameters:
predicate
- A condition tested subsequently for this elements.- Returns:
- a new instance consisting of all elements starting from the first one which does not satisfy the given predicate.
-
init
Dual of tail(), returning all elements except the last.- Specified by:
init
in interfaceTraversable<T>
- Returns:
- a new instance containing all elements except the last.
- Throws:
UnsupportedOperationException
- if this is empty
-
initOption
Dual of tailOption(), returning all elements except the last asOption
.- Specified by:
initOption
in interfaceTraversable<T>
- Returns:
Some(Q)
orNone
if this is empty.
-
tail
Drops the first element of a non-empty Traversable.- Specified by:
tail
in interfaceTraversable<T>
- Returns:
- A new instance of Traversable containing all elements except the first.
- Throws:
UnsupportedOperationException
- if this is empty
-
tailOption
Description copied from interface:Traversable
Drops the first element of a non-empty Traversable and returns anOption
.- Specified by:
tailOption
in interfaceTraversable<T>
- Returns:
Some(traversable)
orNone
if this is empty.
-
retainAll
Description copied from interface:Traversable
Keeps all occurrences of the given elements from this.- Specified by:
retainAll
in interfaceTraversable<T>
- Parameters:
elements
- Elements to be kept.- Returns:
- a Traversable containing all occurrences of the given elements.
-
removeAll
-
removeAll
Deprecated. -
reject
Description copied from interface:Traversable
Returns a new traversable consisting of all elements which do not satisfy the given predicate.The default implementation is equivalent to
filter(predicate.negate()
- Specified by:
reject
in interfaceTraversable<T>
- Parameters:
predicate
- A predicate- Returns:
- a new traversable
-
takeWhile
Description copied from interface:Traversable
Takes elements while the predicate holds for the current element.- Specified by:
takeWhile
in interfaceTraversable<T>
- Parameters:
predicate
- A condition tested subsequently for the contained elements.- Returns:
- a new instance consisting of all elements before the first one which does not satisfy the given predicate.
-
takeUntil
Description copied from interface:Traversable
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.- Specified by:
takeUntil
in interfaceTraversable<T>
- Parameters:
predicate
- A condition tested subsequently for this elements.- Returns:
- a new instance consisting of all elements before the first one which does satisfy the given predicate.
-
peek
Description copied from interface:Value
Performs the givenaction
on the first element if this is an eager implementation. Performs the givenaction
on all elements (the first immediately, successive deferred), if this is a lazy implementation. -
toString
Description copied from interface:Value
Clarifies that values have a proper toString() method implemented.See Object.toString().
-