Modul speiger.src.collections
Klasse DoubleArrayPriorityQueue
java.lang.Object
speiger.src.collections.doubles.queues.AbstractDoublePriorityQueue
speiger.src.collections.doubles.queues.DoubleArrayPriorityQueue
- Alle implementierten Schnittstellen:
Iterable<Double>,DoubleIterable,DoublePriorityQueue
A Array Priority Queue, this is a very unoptimized implementation of the PriorityQueue for very specific usecases.
It allows for duplicated entries and works like
List.indexOf(Object) search.
It is highly suggested to use HeapPriorityQueue otherwise, unless you know why you need this specific implementation-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungDefault ConstructorDoubleArrayPriorityQueue(double[] array) Constructor using a initial arrayDoubleArrayPriorityQueue(double[] array, int size) Constructor using a initial arrayDoubleArrayPriorityQueue(double[] array, int size, DoubleComparator comp) Constructor using a initial array and a custom sorterDoubleArrayPriorityQueue(double[] array, DoubleComparator comp) Constructor using a initial array and a custom sorterDoubleArrayPriorityQueue(int size) Constructor with a Min CapacityDoubleArrayPriorityQueue(int size, DoubleComparator comp) Constructor with a Min Capacity and custom SorterConstructor using a CollectionConstructor using a Collection and a custom sorterConstructor using custom sorter -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidclear()clears all elements within the PriorityQueue, this does not resize the backing arraysbooleancontains(double e) Method to find out if a element is part of the queuecopy()A Function that does a shallow clone of the PriorityQueue itself.intcount(DoublePredicate filter) Helper function to reduce stream usage that allows to count the valid elements.doubledequeue()Method to extract a element from the PriorityQueuevoidenqueue(double e) Method to insert a element into the PriorityQueuedoublefindFirst(DoublePredicate filter) Helper function to reduce stream usage that allows to filter for the first match.doublefirst()Shows the element that is to be returned next<E> voidforEach(E input, ObjectDoubleConsumer<E> action) Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.voidforEach(DoubleConsumer action) A Type Specific foreach function that reduces (un)boxingvoidforEachIndexed(IntDoubleConsumer action) A Indexed forEach implementation that allows you to keep track of how many elements were already iterated over.iterator()Returns an iterator over elements of typeT.booleanmatchesAll(DoublePredicate filter) Helper function to reduce stream usage that allows to filter for all matches.booleanmatchesAny(DoublePredicate filter) Helper function to reduce stream usage that allows to filter for any matches.booleanmatchesNone(DoublePredicate filter) Helper function to reduce stream usage that allows to filter for no matches.voidAllows to notify the Queue to be revalidate its datadoublepeek(int index) Peeking function to see whats inside the queue.doublereduce(double identity, DoubleDoubleUnaryOperator operator) Performs a reduction on the elements of this Iterabledoublereduce(DoubleDoubleUnaryOperator operator) Performs a reduction on the elements of this IterablebooleanremoveFirst(double e) Removes the first found element in the queuebooleanremoveLast(double e) Removes the last found element in the queueintsize()double[]toDoubleArray(double[] input) A method to drop the contents of the Queue without clearing the queuestatic DoubleArrayPriorityQueuewrap(double[] array) Wrapping method to help serializationstatic DoubleArrayPriorityQueuewrap(double[] array, int size) Wrapping method to help serializationstatic DoubleArrayPriorityQueuewrap(double[] array, int size, DoubleComparator comp) Wrapping method to help serialization, using a custom sorterstatic DoubleArrayPriorityQueuewrap(double[] array, DoubleComparator comp) Wrapping method to help serialization, using a custom sorterVon Klasse geerbte Methoden speiger.src.collections.doubles.queues.AbstractDoublePriorityQueue
equals, hashCode, toStringVon Schnittstelle geerbte Methoden speiger.src.collections.doubles.collections.DoubleIterable
arrayflatMap, asAsync, distinct, filter, flatMap, forEach, limit, map, peek, pour, pourAsList, pourAsSet, repeat, sorted, spliteratorVon Schnittstelle geerbte Methoden speiger.src.collections.doubles.queues.DoublePriorityQueue
enqueueAll, enqueueAll, enqueueAll, enqueueAll, isEmpty, synchronizeQueue, synchronizeQueue, toDoubleArray
-
Konstruktordetails
-
DoubleArrayPriorityQueue
public DoubleArrayPriorityQueue()Default Constructor -
DoubleArrayPriorityQueue
Constructor using custom sorter- Parameter:
comp- Comparator to sort the Array. Can be null
-
DoubleArrayPriorityQueue
public DoubleArrayPriorityQueue(int size) Constructor with a Min Capacity- Parameter:
size- the initial capacity of the backing array- Löst aus:
IllegalStateException- if the initial size is smaller 0
-
DoubleArrayPriorityQueue
Constructor with a Min Capacity and custom Sorter- Parameter:
size- the initial capacity of the backing arraycomp- Comparator to sort the Array. Can be null- Löst aus:
IllegalStateException- if the initial size is smaller 0
-
DoubleArrayPriorityQueue
public DoubleArrayPriorityQueue(double[] array) Constructor using a initial array- Parameter:
array- the Array that should be used
-
DoubleArrayPriorityQueue
public DoubleArrayPriorityQueue(double[] array, int size) Constructor using a initial array- Parameter:
array- the Array that should be usedsize- the amount of elements found within the array- Löst aus:
NegativeArraySizeException- if size is smaller then 0
-
DoubleArrayPriorityQueue
Constructor using a initial array and a custom sorter- Parameter:
array- the Array that should be usedcomp- Comparator to sort the Array. Can be null
-
DoubleArrayPriorityQueue
Constructor using a initial array and a custom sorter- Parameter:
array- the Array that should be usedsize- the amount of elements found within the arraycomp- Comparator to sort the Array. Can be null- Löst aus:
NegativeArraySizeException- if size is smaller then 0
-
DoubleArrayPriorityQueue
Constructor using a Collection- Parameter:
c- the Collection that should be used
-
DoubleArrayPriorityQueue
Constructor using a Collection and a custom sorter- Parameter:
c- the Collection that should be usedcomp- Comparator to sort the Array. Can be null
-
-
Methodendetails
-
wrap
Wrapping method to help serialization- Parameter:
array- the array that should be used- Gibt zurück:
- a ArrayPriorityQueue containing the original input array
-
wrap
Wrapping method to help serialization- Parameter:
array- the array that should be usedsize- the amount of elements within the array- Gibt zurück:
- a ArrayPriorityQueue containing the original input array
-
wrap
Wrapping method to help serialization, using a custom sorter- Parameter:
array- the array that should be usedcomp- Comparator to sort the Array. Can be null- Gibt zurück:
- a ArrayPriorityQueue containing the original input array
-
wrap
Wrapping method to help serialization, using a custom sorter- Parameter:
array- the array that should be usedsize- the amount of elements within the arraycomp- Comparator to sort the Array. Can be null- Gibt zurück:
- a ArrayPriorityQueue containing the original input array
-
enqueue
public void enqueue(double e) Beschreibung aus Schnittstelle kopiert:DoublePriorityQueueMethod to insert a element into the PriorityQueue- Parameter:
e- the element that should be inserted
-
dequeue
public double dequeue()Beschreibung aus Schnittstelle kopiert:DoublePriorityQueueMethod to extract a element from the PriorityQueue- Gibt zurück:
- a element from the Queue
-
first
public double first()Beschreibung aus Schnittstelle kopiert:DoublePriorityQueueShows the element that is to be returned next- Gibt zurück:
- the first element in the Queue
-
peek
public double peek(int index) Beschreibung aus Schnittstelle kopiert:DoublePriorityQueuePeeking function to see whats inside the queue.- Parameter:
index- of the element that is requested to be viewed.- Gibt zurück:
- the element that is requested
-
contains
public boolean contains(double e) Beschreibung aus Schnittstelle kopiert:DoublePriorityQueueMethod to find out if a element is part of the queue- Parameter:
e- the element that is searched for- Gibt zurück:
- true if the element is in the queue
-
removeFirst
public boolean removeFirst(double e) Beschreibung aus Schnittstelle kopiert:DoublePriorityQueueRemoves the first found element in the queue- Parameter:
e- the element that should be removed- Gibt zurück:
- if a searched element was removed
-
removeLast
public boolean removeLast(double e) Beschreibung aus Schnittstelle kopiert:DoublePriorityQueueRemoves the last found element in the queue- Parameter:
e- the element that should be removed- Gibt zurück:
- if a searched element was removed
-
onChanged
public void onChanged()Beschreibung aus Schnittstelle kopiert:DoublePriorityQueueAllows to notify the Queue to be revalidate its data -
size
public int size()- Gibt zurück:
- the amount of elements that are stored in the PriorityQueue
-
clear
public void clear()Beschreibung aus Schnittstelle kopiert:DoublePriorityQueueclears all elements within the PriorityQueue, this does not resize the backing arrays -
forEach
Beschreibung aus Schnittstelle kopiert:DoubleIterableA Type Specific foreach function that reduces (un)boxing- Parameter:
action- The action to be performed for each element- Siehe auch:
-
forEachIndexed
Beschreibung aus Schnittstelle kopiert:DoubleIterableA Indexed forEach implementation that allows you to keep track of how many elements were already iterated over.- Parameter:
action- The action to be performed for each element
-
forEach
Beschreibung aus Schnittstelle kopiert:DoubleIterableHelper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.- Typparameter:
E- the generic type of the Object- Parameter:
input- the object that should be includedaction- The action to be performed for each element
-
matchesAny
Beschreibung aus Schnittstelle kopiert:DoubleIterableHelper function to reduce stream usage that allows to filter for any matches.- Parameter:
filter- that should be applied- Gibt zurück:
- true if any matches were found
-
matchesNone
Beschreibung aus Schnittstelle kopiert:DoubleIterableHelper function to reduce stream usage that allows to filter for no matches.- Parameter:
filter- that should be applied- Gibt zurück:
- true if no matches were found
-
matchesAll
Beschreibung aus Schnittstelle kopiert:DoubleIterableHelper function to reduce stream usage that allows to filter for all matches.- Parameter:
filter- that should be applied- Gibt zurück:
- true if all matches.
-
reduce
Beschreibung aus Schnittstelle kopiert:DoubleIterablePerforms a reduction on the elements of this Iterable- Parameter:
identity- the start valueoperator- the operation that should be applied- Gibt zurück:
- the reduction result, returns identity if nothing was found
-
reduce
Beschreibung aus Schnittstelle kopiert:DoubleIterablePerforms a reduction on the elements of this Iterable- Parameter:
operator- the operation that should be applied- Gibt zurück:
- the reduction result, returns null value if nothing was found
-
findFirst
Beschreibung aus Schnittstelle kopiert:DoubleIterableHelper function to reduce stream usage that allows to filter for the first match.- Parameter:
filter- that should be applied- Gibt zurück:
- the found value or the null equivalent variant.
-
count
Beschreibung aus Schnittstelle kopiert:DoubleIterableHelper function to reduce stream usage that allows to count the valid elements.- Parameter:
filter- that should be applied- Gibt zurück:
- the amount of Valid Elements
-
iterator
Beschreibung aus Schnittstelle kopiert:DoubleIterableReturns an iterator over elements of typeT.- Gibt zurück:
- an Iterator.
-
copy
Beschreibung aus Schnittstelle kopiert:DoublePriorityQueueA Function that does a shallow clone of the PriorityQueue itself. This function is more optimized then a copy constructor since the PriorityQueue does not have to be unsorted/resorted. It can be compared to Cloneable but with less exception risk- Gibt zurück:
- a Shallow Copy of the PriorityQueue
-
comparator
- Gibt zurück:
- the sorter of the Queue, can be null
-
toDoubleArray
public double[] toDoubleArray(double[] input) Beschreibung aus Schnittstelle kopiert:DoublePriorityQueueA method to drop the contents of the Queue without clearing the queue- Parameter:
input- where the elements should be inserted to. If it does not fit then it creates a new appropiatly created array- Gibt zurück:
- the contents of the queue into a seperate array.
-