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 QDrops elements while the predicate holds for the current element.abstract QEnqueues a new element.Enqueues the given elements.abstract QenqueueAll(Iterable<? extends T> elements) Enqueues the given elements.abstract Qinit()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 givenactionon 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 Qtail()Drops the first element of a non-empty Traversable.Drops the first element of a non-empty Traversable and returns anOption.abstract QTakes 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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Foldable
fold, reduce, reduceOptionMethods inherited from interface 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, zipWithIndexMethods inherited from interface 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
-
enqueue
-
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
Queueinstance, 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
Queueinstance, 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
-
dropUntil
Description copied from interface:TraversableDrops elements until the predicate holds for the current element.- Specified by:
dropUntilin 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:TraversableDrops 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:
dropWhilein 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:
initin 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:
initOptionin interfaceTraversable<T>- Returns:
Some(Q)orNoneif this is empty.
-
tail
Drops the first element of a non-empty Traversable.- Specified by:
tailin 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:TraversableDrops the first element of a non-empty Traversable and returns anOption.- Specified by:
tailOptionin interfaceTraversable<T>- Returns:
Some(traversable)orNoneif this is empty.
-
retainAll
Description copied from interface:TraversableKeeps all occurrences of the given elements from this.- Specified by:
retainAllin 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:TraversableReturns 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:
rejectin interfaceTraversable<T>- Parameters:
predicate- A predicate- Returns:
- a new traversable
-
takeWhile
Description copied from interface:TraversableTakes elements while the predicate holds for the current element.- Specified by:
takeWhilein 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:TraversableTakes 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:
takeUntilin 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:ValuePerforms the givenactionon the first element if this is an eager implementation. Performs the givenactionon all elements (the first immediately, successive deferred), if this is a lazy implementation. -
toString
-