Top Description Fields Constructors Methods
io.vavr.collection

public final Class PriorityQueue<T>

Additional top-level class in compilation unit: PriorityQueueBase.

extends AbstractQueue<T, PriorityQueue<T>>
implements Serializable, Ordered<T>
Class Inheritance
All Implemented Interfaces
io.vavr.collection.Ordered, java.io.Serializable
Imports
io.vavr.*, io.vavr.collection.PriorityQueueBase.*, java.io.Serializable, java.util.*, java.util.function.*, java.util.stream.Collector

A PriorityQueue.
Author
Pap Lőrinc

Field Summary

Modifier and TypeField and Description
private final Comparator<? super T>
private final Seq<PriorityQueueBase.Node<T>>
private static final long
private final int

Constructor Summary

AccessConstructor and Description
private
PriorityQueue(Comparator<? super T> comparator, Seq<PriorityQueueBase.Node<T>> forest, int size)

Method Summary

Modifier and TypeMethod and Description
public <R> PriorityQueue<R>
collect(PartialFunction<? super T, ? extends R>
A function that is not necessarily defined of all elements of this traversable.
partialFunction
)

Implements io.vavr.collection.Traversable.collect.

Collects all elements that are in the domain of the given partialFunction by mapping the elements to type R.

public static <
Component type of the PriorityQueue.
T
>
Collector<T, ArrayList<T>, PriorityQueue<T>>

Returns:

A PriorityQueue<T> Collector.
collector
()

Returns a Collector which may be used in conjunction with java.util.stream.Stream#collect(Collector) to obtain a PriorityQueue<T>.

public Comparator<T>
comparator()

Implements io.vavr.collection.Ordered.comparator.

Returns the comparator which defines the order of the elements contained in this collection.

public Tuple2<T, PriorityQueue<T>>
dequeue()

Overrides io.vavr.collection.AbstractQueue.dequeue.

Removes an element from this Queue.

public PriorityQueue<T>
distinct()

Implements io.vavr.collection.Traversable.distinct.

Returns a new version of this which contains no duplicates.

public PriorityQueue<T>
distinctBy(Comparator<? super T>
A comparator
comparator
)

Implements io.vavr.collection.Traversable.distinctBy.

Returns a new version of this which contains no duplicates.

public <U> PriorityQueue<T>
distinctBy(Function<? super T, ? extends U>
A key extractor
keyExtractor
)

Implements io.vavr.collection.Traversable.distinctBy.

Returns a new version of this which contains no duplicates.

public PriorityQueue<T>
drop(int
The number of elements to drop.
n
)

Implements io.vavr.collection.Traversable.drop.

Drops the first n elements of this or all elements, if this length < n.

public PriorityQueue<T>
dropRight(int
The number of elements to drop.
n
)

Implements io.vavr.collection.Traversable.dropRight.

Drops the last n elements of this or all elements, if this length < n.

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

Implements abstract io.vavr.collection.AbstractQueue.dropWhile.

Implements io.vavr.collection.Traversable.dropWhile.

Drops elements while the predicate holds for the current element.

public static <
Component type
T extends Comparable<? super T>
>
PriorityQueue<T>

Returns:

The empty PriorityQueue.
empty
()

Returns the empty PriorityQueue.

public static <T> PriorityQueue<T>
empty(Comparator<? super T> comparator)

public PriorityQueue<T>

Returns:

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

Implements abstract io.vavr.collection.AbstractQueue.enqueue.

Enqueues a new element.

public PriorityQueue<T>

Returns:

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

Implements abstract io.vavr.collection.AbstractQueue.enqueueAll.

Enqueues the given elements.

public boolean
equals(Object
an object, may be null
o
)

Overrides java.lang.Object.equals.

Implements io.vavr.collection.Traversable.equals.

In Vavr there are four basic classes of collections:

  • Seq (sequential elements)
  • Set (distinct elements)
  • Map (indexed elements)
  • Multimap (indexed collections)
public static <
Component type of the PriorityQueue
T
>
PriorityQueue<T>

Returns:

A PriorityQueue of size size, where each element contains the result supplied by supplier.
fill
(int
The number of elements in the PriorityQueue
size
,
Supplier<? extends T>
The Supplier computing element values
supplier
)

Returns a PriorityQueue containing size values supplied by a given Supplier supplier.

public static <
Component type of the PriorityQueue
T
>
PriorityQueue<T>

Returns:

A PriorityQueue of size size, where each element is the given element.
fill
(int
The number of elements in the PriorityQueue
size
,
T
The element
element
)

Returns a PriorityQueue containing n times the given element

public PriorityQueue<T>
filter(Predicate<? super T>
A predicate
predicate
)

Implements io.vavr.collection.Traversable.filter.

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

public <U> PriorityQueue<U>
flatMap(Function<? super T, ? extends Iterable<? extends U>>
A mapper
mapper
)

Implements io.vavr.collection.Traversable.flatMap.

FlatMaps this Traversable.

public <U> PriorityQueue<U>
flatMap(Comparator<U> comparator, Function<? super T, ? extends Iterable<? extends U>> mapper)

public <U> U

Returns:

an accumulated version of this.
foldRight
(U
Value to start the accumulation with.
zero
,
BiFunction<? super T, ? super U, ? extends U>
The accumulator function.
accumulator
)

Implements io.vavr.collection.Traversable.foldRight.

Accumulates the elements of this PriorityQueue by successively calling the given function f from the right, starting with a value zero of type B.

public <C> Map<C, ? extends PriorityQueue<T>>
groupBy(Function<? super T, ? extends C>
A function which classifies elements into classes
classifier
)

Implements io.vavr.collection.Traversable.groupBy.

Groups this elements by classifying the elements.

public Iterator<? extends PriorityQueue<T>>
grouped(int
a positive block size
size
)

Implements io.vavr.collection.Traversable.grouped.

Groups this Traversable into fixed size blocks.

public boolean

Returns:

true, if this PriorityQueue is known to have a finite size, false otherwise.
hasDefiniteSize
()

Implements io.vavr.collection.Traversable.hasDefiniteSize.

Checks if this PriorityQueue is known to have a finite size.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements io.vavr.collection.Traversable.hashCode.

Returns the hash code of this collection.

public T

Returns:

The first element of this PriorityQueue.
head
()

Implements io.vavr.collection.Traversable.head.

Returns the first element of a non-empty PriorityQueue.

public PriorityQueue<T>

Returns:

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

Implements abstract io.vavr.collection.AbstractQueue.init.

Implements io.vavr.collection.Traversable.init.

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

public boolean

Returns:

false
isAsync
()

Implements io.vavr.Value.isAsync.

A PriorityQueue is computed synchronously.

public boolean
isEmpty()

Overrides default io.vavr.collection.Traversable.isEmpty.

Checks if this Traversable is empty.

public boolean

Returns:

false
isLazy
()

Implements io.vavr.Value.isLazy.

A PriorityQueue is computed eagerly.

public boolean
isOrdered()

Overrides default io.vavr.collection.Traversable.isOrdered.

Checks if this Traversable is ordered

public boolean

Returns:

true, if this PriorityQueue is known to be traversable repeatedly, false otherwise.
isTraversableAgain
()

Implements io.vavr.collection.Traversable.isTraversableAgain.

Checks if this PriorityQueue can be repeatedly traversed.

public T
last()

Implements io.vavr.collection.Traversable.last.

Dual of head(), returning the last element.

public int

Returns:

the number of elements
length
()

Implements io.vavr.collection.Traversable.length.

Computes the number of elements of this PriorityQueue.

public <U> PriorityQueue<U>
map(Function<? super T, ? extends U>
A mapper.
mapper
)

Implements io.vavr.collection.Traversable.map.

Maps the elements of this Traversable to elements of a new type preserving their order, if any.

public <U> PriorityQueue<U>
map(Comparator<U> comparator, Function<? super T, ? extends U> mapper)

public PriorityQueue<T>
merge(PriorityQueue<T> target)

public static <
Component type of the PriorityQueue.
T
>
PriorityQueue<T>

Returns:

the given PriorityQueue instance as narrowed type PriorityQueue<T>.
narrow
(PriorityQueue<? extends T>
An PriorityQueue.
queue
)

Narrows a widened PriorityQueue<?

public static <T extends Comparable<? super T>> PriorityQueue<T>
of(T element)

public static <T extends Comparable<? super T>> PriorityQueue<T>
of(T... elements)

public static <T> PriorityQueue<T>
of(Comparator<? super T> comparator, T element)

public static <T> PriorityQueue<T>
of(Comparator<? super T> comparator, T... elements)

public static <T extends Comparable<? super T>> PriorityQueue<T>
ofAll(Iterable<? extends T> elements)

public static <T> PriorityQueue<T>
ofAll(Comparator<? super T> comparator, Iterable<? extends T> elements)

public static <T extends Comparable<? super T>> PriorityQueue<T>
ofAll(Stream<? extends T> javaStream)

public static <T> PriorityQueue<T>
ofAll(Comparator<? super T> comparator, Stream<? extends T> javaStream)

public PriorityQueue<T>

Returns:

this PriorityQueue if it is nonempty, otherwise PriorityQueue created from iterable, using existing comparator.
orElse
(Iterable<? extends T>
An alternative Traversable
other
)

Implements io.vavr.collection.Traversable.orElse.

Returns this PriorityQueue if it is nonempty, otherwise PriorityQueue created from iterable, using existing comparator.

public PriorityQueue<T>

Returns:

this PriorityQueue if it is nonempty, otherwise PriorityQueue created from result of evaluating supplier, using existing comparator.
orElse
(Supplier<? extends Iterable<? extends T>>
An alternative Traversable
supplier
)

Implements io.vavr.collection.Traversable.orElse.

Returns this PriorityQueue if it is nonempty, otherwise PriorityQueue created from result of evaluating supplier, using existing comparator.

public Tuple2<? extends PriorityQueue<T>, ? extends PriorityQueue<T>>
partition(Predicate<? super T>
A predicate which classifies an element if it is in the first or the second traversable.
predicate
)

Implements io.vavr.collection.Traversable.partition.

Creates a partition of this Traversable by splitting this elements in two in distinct traversables according to a predicate.

public PriorityQueue<T>
replace(T
An element to be substituted.
currentElement
,
T
A replacement for currentElement.
newElement
)

Implements io.vavr.collection.Traversable.replace.

Replaces the first occurrence (if exists) of the given currentElement with newElement.

public PriorityQueue<T>
replaceAll(T
An element to be substituted.
currentElement
,
T
A replacement for currentElement.
newElement
)

Implements io.vavr.collection.Traversable.replaceAll.

Replaces all occurrences of the given currentElement with newElement.

public PriorityQueue<T>
scan(T
neutral element for the operator op
zero
,
BiFunction<? super T, ? super T, ? extends T>
the associative operator for the scan
operation
)

Implements io.vavr.collection.Traversable.scan.

Computes a prefix scan of the elements of the collection.

public <U> PriorityQueue<U>
scanLeft(U
the initial value
zero
,
BiFunction<? super U, ? super T, ? extends U>
the binary operator applied to the intermediate result and the element
operation
)

Implements io.vavr.collection.Traversable.scanLeft.

Produces a collection containing cumulative results of applying the operator going left to right.

public <U> PriorityQueue<U>
scanRight(U
the initial value
zero
,
BiFunction<? super T, ? super U, ? extends U>
the binary operator applied to the intermediate result and the element
operation
)

Implements io.vavr.collection.Traversable.scanRight.

Produces a collection containing cumulative results of applying the operator going right to left.

public Iterator<? extends PriorityQueue<T>>
slideBy(Function<? super T, ?>
A function which classifies elements into classes
classifier
)

Implements io.vavr.collection.Traversable.slideBy.

Slides a non-overlapping window of a variable size over this Traversable.

public Iterator<? extends PriorityQueue<T>>
sliding(int
a positive window size
size
)

Implements io.vavr.collection.Traversable.sliding.

Slides a window of a specific size and step size 1 over this Traversable by calling sliding(int, int).

public Iterator<? extends PriorityQueue<T>>
sliding(int
a positive window size
size
,
int
a positive step size
step
)

Implements io.vavr.collection.Traversable.sliding.

Slides a window of a specific size and step size over this Traversable.

public Tuple2<? extends PriorityQueue<T>, ? extends PriorityQueue<T>>
span(Predicate<? super T>
A predicate.
predicate
)

Implements io.vavr.collection.Traversable.span.

Returns a tuple where the first element is the longest prefix of elements that satisfy the given predicate and the second element is the remainder.

public String
stringPrefix()

Implements io.vavr.Value.stringPrefix.

Returns the name of this Value type, which is used by toString().

public static <
Component type of the PriorityQueue
T
>
PriorityQueue<T>

Returns:

A PriorityQueue consisting of elements function(0),function(1), ..., function(size - 1)
tabulate
(int
The number of elements in the PriorityQueue
size
,
Function<? super Integer, ? extends T>
The Function computing element values
function
)

Returns a PriorityQueue containing size values of a given Function function over a range of integer values from 0 to size - 1.

public PriorityQueue<T>

Returns:

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

Implements abstract io.vavr.collection.AbstractQueue.tail.

Implements io.vavr.collection.Traversable.tail.

Drops the first element of a non-empty PriorityQueue.

public PriorityQueue<T>
take(int
The number of elements to take.
n
)

Implements io.vavr.collection.Traversable.take.

Takes the first n elements of this or all elements, if this length < n.

public PriorityQueue<T>
takeRight(int
The number of elements to take.
n
)

Implements io.vavr.collection.Traversable.takeRight.

Takes the last n elements of this or all elements, if this length < n.

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

Implements abstract io.vavr.collection.AbstractQueue.takeUntil.

Implements io.vavr.collection.Traversable.takeUntil.

Takes elements until the predicate holds for the current element.

public List<T>
toList()

Overrides default io.vavr.Value.toList.

Converts this to a List.

public <T1, T2> Tuple2<? extends PriorityQueue<T1>, ? extends PriorityQueue<T2>>
unzip(Function<? super T, Tuple2<? extends T1, ? extends T2>>
a function which converts elements of this to pairs
unzipper
)

Implements io.vavr.collection.Traversable.unzip.

Unzips this elements by mapping this elements to pairs which are subsequently split into two distinct sets.

public <T1, T2, T3> Tuple3<? extends PriorityQueue<T1>, ? extends PriorityQueue<T2>, ? extends PriorityQueue<T3>>
unzip3(Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>>
a function which converts elements of this to pairs
unzipper
)

Implements io.vavr.collection.Traversable.unzip3.

Unzips this elements by mapping this elements to triples which are subsequently split into three distinct sets.

private PriorityQueue<T>
with(Seq<PriorityQueueBase.Node<T>> forest, int size)

public <U> PriorityQueue<Tuple2<T, U>>
zip(Iterable<? extends U>
The Iterable providing the second half of each result pair.
that
)

Implements io.vavr.collection.Traversable.zip.

Returns a traversable formed from this traversable and another Iterable collection by combining corresponding elements in pairs.

public <U> PriorityQueue<Tuple2<T, U>>
zipAll(Iterable<? extends U>
The Iterable providing the second half of each result pair.
that
,
T
The element to be used to fill up the result if this traversable is shorter than that.
thisElem
,
U
The element to be used to fill up the result if that is shorter than this traversable.
thatElem
)

Implements io.vavr.collection.Traversable.zipAll.

Returns a traversable formed from this traversable and another Iterable by combining corresponding elements in pairs.

public <U, R> PriorityQueue<R>
zipWith(Iterable<? extends U>
The Iterable providing the second parameter of the mapper.
that
,
BiFunction<? super T, ? super U, ? extends R>
a mapper.
mapper
)

Implements io.vavr.collection.Traversable.zipWith.

Returns a traversable formed from this traversable and another Iterable collection by mapping elements.

public PriorityQueue<Tuple2<T, Integer>>
zipWithIndex()

Implements io.vavr.collection.Traversable.zipWithIndex.

Zips this traversable with its indices.

public <U> PriorityQueue<U>
zipWithIndex(BiFunction<? super T, ? super Integer, ? extends U>
a mapper.
mapper
)

Implements io.vavr.collection.Traversable.zipWithIndex.

Zips this traversable with its indices by applying mapper provided.

Inherited from io.vavr.collection.AbstractQueue:
dequeueOptiondropUntilenqueueinitOptionpeekpeekpeekOptionrejectremoveAllremoveAllretainAlltailOptiontakeWhiletoString