Modul speiger.src.collections
Klasse LongArrayFIFOQueue
java.lang.Object
speiger.src.collections.longs.queues.AbstractLongPriorityQueue
speiger.src.collections.longs.queues.LongArrayFIFOQueue
- Alle implementierten Schnittstellen:
Iterable<Long>,LongIterable,LongPriorityDequeue,LongPriorityQueue,ITrimmable
public class LongArrayFIFOQueue
extends AbstractLongPriorityQueue
implements LongPriorityDequeue, ITrimmable
A Simple First In First Out Priority Queue that is a Good Replacement for a linked list (or ArrayDequeue)
Its specific implementation uses a backing array that grows and shrinks as it is needed.
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final intThe Minimum Capacity that is allowed -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungDefault ConstrutorLongArrayFIFOQueue(int capacity) Constructor with a Min CapacityLongArrayFIFOQueue(long[] values) Constructor using a initial arrayLongArrayFIFOQueue(long[] values, int size) Constructor using a initial arrayLongArrayFIFOQueue(long[] values, int offset, int size) Constructor using a initial array -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidclear()clears all elements within the PriorityQueue, this does not resize the backing arraysvoidclearAndTrim(int size) Trims the collection down to the requested size and clears all elements while doing sobooleancontains(long 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(LongPredicate filter) Helper function to reduce stream usage that allows to count the valid elements.longdequeue()Method to extract a element from the PriorityQueuelongA Method to remove a element from the last place instead of the firstvoidenqueue(long e) Method to insert a element into the PriorityQueuevoidenqueueFirst(long e) Method to insert a element into the first Index instead of the last.longfindFirst(LongPredicate filter) Helper function to reduce stream usage that allows to filter for the first match.<E> voidforEach(E input, ObjectLongConsumer<E> action) Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.voidforEach(LongConsumer action) A Type Specific foreach function that reduces (un)boxingvoidforEachIndexed(IntLongConsumer 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(LongPredicate filter) Helper function to reduce stream usage that allows to filter for all matches.booleanmatchesAny(LongPredicate filter) Helper function to reduce stream usage that allows to filter for any matches.booleanmatchesNone(LongPredicate filter) Helper function to reduce stream usage that allows to filter for no matches.voidAllows to notify the Queue to be revalidate its datalongpeek(int index) Peeking function to see whats inside the queue.longreduce(long identity, LongLongUnaryOperator operator) Performs a reduction on the elements of this Iterablelongreduce(LongLongUnaryOperator operator) Performs a reduction on the elements of this IterablebooleanremoveFirst(long e) Removes the first found element in the queuebooleanremoveLast(long e) Removes the last found element in the queueintsize()long[]toLongArray(long[] input) A method to drop the contents of the Queue without clearing the queuebooleantrim(int size) Trims the original collection down to the size of the current elements or the requested size depending which is biggerVon Klasse geerbte Methoden speiger.src.collections.longs.queues.AbstractLongPriorityQueue
equals, hashCode, toStringVon Schnittstelle geerbte Methoden speiger.src.collections.utils.ITrimmable
clearAndTrim, trimVon Schnittstelle geerbte Methoden speiger.src.collections.longs.collections.LongIterable
arrayflatMap, asAsync, distinct, filter, flatMap, forEach, limit, map, peek, pour, pourAsList, pourAsSet, repeat, sorted, spliteratorVon Schnittstelle geerbte Methoden speiger.src.collections.longs.queues.LongPriorityDequeue
enqueueAllFirst, enqueueAllFirst, enqueueAllFirst, enqueueAllFirst, last, synchronizeQueue, synchronizeQueueVon Schnittstelle geerbte Methoden speiger.src.collections.longs.queues.LongPriorityQueue
enqueueAll, enqueueAll, enqueueAll, enqueueAll, first, isEmpty, toLongArray
-
Felddetails
-
MIN_CAPACITY
public static final int MIN_CAPACITYThe Minimum Capacity that is allowed- Siehe auch:
-
-
Konstruktordetails
-
LongArrayFIFOQueue
public LongArrayFIFOQueue(long[] values) Constructor using a initial array- Parameter:
values- the Array that should be used
-
LongArrayFIFOQueue
public LongArrayFIFOQueue(long[] values, int size) Constructor using a initial array- Parameter:
values- the Array that should be usedsize- the amount of elements that are in the initial array- Löst aus:
IllegalStateException- if values is smaller then size
-
LongArrayFIFOQueue
public LongArrayFIFOQueue(long[] values, int offset, int size) Constructor using a initial array- Parameter:
values- the Array that should be usedoffset- where to begin in the initial arraysize- the amount of elements that are in the initial array- Löst aus:
IllegalStateException- if values is smaller then size
-
LongArrayFIFOQueue
public LongArrayFIFOQueue(int capacity) Constructor with a Min Capacity- Parameter:
capacity- the initial capacity of the backing array- Löst aus:
IllegalStateException- if the initial size is smaller 0
-
LongArrayFIFOQueue
public LongArrayFIFOQueue()Default Construtor
-
-
Methodendetails
-
iterator
Beschreibung aus Schnittstelle kopiert:LongIterableReturns an iterator over elements of typeT.- Angegeben von:
iteratorin SchnittstelleIterable<Long>- Angegeben von:
iteratorin SchnittstelleLongIterable- Gibt zurück:
- an Iterator.
-
size
public int size()- Angegeben von:
sizein SchnittstelleLongPriorityQueue- Gibt zurück:
- the amount of elements that are stored in the PriorityQueue
-
clear
public void clear()Beschreibung aus Schnittstelle kopiert:LongPriorityQueueclears all elements within the PriorityQueue, this does not resize the backing arrays- Angegeben von:
clearin SchnittstelleLongPriorityQueue
-
enqueue
public void enqueue(long e) Beschreibung aus Schnittstelle kopiert:LongPriorityQueueMethod to insert a element into the PriorityQueue- Angegeben von:
enqueuein SchnittstelleLongPriorityQueue- Parameter:
e- the element that should be inserted
-
enqueueFirst
public void enqueueFirst(long e) Beschreibung aus Schnittstelle kopiert:LongPriorityDequeueMethod to insert a element into the first Index instead of the last.- Angegeben von:
enqueueFirstin SchnittstelleLongPriorityDequeue- Parameter:
e- the element that should be inserted into the first place
-
dequeue
public long dequeue()Beschreibung aus Schnittstelle kopiert:LongPriorityQueueMethod to extract a element from the PriorityQueue- Angegeben von:
dequeuein SchnittstelleLongPriorityQueue- Gibt zurück:
- a element from the Queue
-
dequeueLast
public long dequeueLast()Beschreibung aus Schnittstelle kopiert:LongPriorityDequeueA Method to remove a element from the last place instead of the first- Angegeben von:
dequeueLastin SchnittstelleLongPriorityDequeue- Gibt zurück:
- the last element inserted
-
peek
public long peek(int index) Beschreibung aus Schnittstelle kopiert:LongPriorityQueuePeeking function to see whats inside the queue.- Angegeben von:
peekin SchnittstelleLongPriorityQueue- Parameter:
index- of the element that is requested to be viewed.- Gibt zurück:
- the element that is requested
-
contains
public boolean contains(long e) Beschreibung aus Schnittstelle kopiert:LongPriorityQueueMethod to find out if a element is part of the queue- Angegeben von:
containsin SchnittstelleLongPriorityQueue- Parameter:
e- the element that is searched for- Gibt zurück:
- true if the element is in the queue
-
removeFirst
public boolean removeFirst(long e) Beschreibung aus Schnittstelle kopiert:LongPriorityQueueRemoves the first found element in the queue- Angegeben von:
removeFirstin SchnittstelleLongPriorityQueue- Parameter:
e- the element that should be removed- Gibt zurück:
- if a searched element was removed
-
removeLast
public boolean removeLast(long e) Beschreibung aus Schnittstelle kopiert:LongPriorityQueueRemoves the last found element in the queue- Angegeben von:
removeLastin SchnittstelleLongPriorityQueue- 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:LongPriorityQueueAllows to notify the Queue to be revalidate its data- Angegeben von:
onChangedin SchnittstelleLongPriorityQueue
-
copy
Beschreibung aus Schnittstelle kopiert:LongPriorityQueueA 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- Angegeben von:
copyin SchnittstelleLongPriorityDequeue- Angegeben von:
copyin SchnittstelleLongPriorityQueue- Gibt zurück:
- a Shallow Copy of the PriorityQueue
-
comparator
- Angegeben von:
comparatorin SchnittstelleLongPriorityQueue- Gibt zurück:
- the sorter of the Queue, can be null
-
forEach
Beschreibung aus Schnittstelle kopiert:LongIterableA Type Specific foreach function that reduces (un)boxing- Angegeben von:
forEachin SchnittstelleLongIterable- Parameter:
action- The action to be performed for each element- Siehe auch:
-
forEachIndexed
Beschreibung aus Schnittstelle kopiert:LongIterableA Indexed forEach implementation that allows you to keep track of how many elements were already iterated over.- Angegeben von:
forEachIndexedin SchnittstelleLongIterable- Parameter:
action- The action to be performed for each element
-
forEach
Beschreibung aus Schnittstelle kopiert:LongIterableHelper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.- Angegeben von:
forEachin SchnittstelleLongIterable- 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:LongIterableHelper function to reduce stream usage that allows to filter for any matches.- Angegeben von:
matchesAnyin SchnittstelleLongIterable- Parameter:
filter- that should be applied- Gibt zurück:
- true if any matches were found
-
matchesNone
Beschreibung aus Schnittstelle kopiert:LongIterableHelper function to reduce stream usage that allows to filter for no matches.- Angegeben von:
matchesNonein SchnittstelleLongIterable- Parameter:
filter- that should be applied- Gibt zurück:
- true if no matches were found
-
matchesAll
Beschreibung aus Schnittstelle kopiert:LongIterableHelper function to reduce stream usage that allows to filter for all matches.- Angegeben von:
matchesAllin SchnittstelleLongIterable- Parameter:
filter- that should be applied- Gibt zurück:
- true if all matches.
-
findFirst
Beschreibung aus Schnittstelle kopiert:LongIterableHelper function to reduce stream usage that allows to filter for the first match.- Angegeben von:
findFirstin SchnittstelleLongIterable- Parameter:
filter- that should be applied- Gibt zurück:
- the found value or the null equivalent variant.
-
reduce
Beschreibung aus Schnittstelle kopiert:LongIterablePerforms a reduction on the elements of this Iterable- Angegeben von:
reducein SchnittstelleLongIterable- 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:LongIterablePerforms a reduction on the elements of this Iterable- Angegeben von:
reducein SchnittstelleLongIterable- Parameter:
operator- the operation that should be applied- Gibt zurück:
- the reduction result, returns null value if nothing was found
-
count
Beschreibung aus Schnittstelle kopiert:LongIterableHelper function to reduce stream usage that allows to count the valid elements.- Angegeben von:
countin SchnittstelleLongIterable- Parameter:
filter- that should be applied- Gibt zurück:
- the amount of Valid Elements
-
trim
public boolean trim(int size) Beschreibung aus Schnittstelle kopiert:ITrimmableTrims the original collection down to the size of the current elements or the requested size depending which is bigger- Angegeben von:
trimin SchnittstelleITrimmable- Parameter:
size- the requested trim size.- Gibt zurück:
- if the internal array has been trimmed.
-
clearAndTrim
public void clearAndTrim(int size) Trims the collection down to the requested size and clears all elements while doing so- Angegeben von:
clearAndTrimin SchnittstelleITrimmable- Parameter:
size- the amount of elements that should be allowed- Note:
- this will enforce minimum size of the collection itself
-
toLongArray
public long[] toLongArray(long[] input) Beschreibung aus Schnittstelle kopiert:LongPriorityQueueA method to drop the contents of the Queue without clearing the queue- Angegeben von:
toLongArrayin SchnittstelleLongPriorityQueue- 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.
-