T - the keyType of elements maintained by this Collectionpublic class ObjectArrayFIFOQueue<T> extends AbstractObjectPriorityQueue<T> implements ObjectPriorityDequeue<T>, ITrimmable
| Modifier and Type | Field and Description |
|---|---|
static int |
MIN_CAPACITY
The Minimum Capacity that is allowed
|
| Constructor and Description |
|---|
ObjectArrayFIFOQueue()
Default Construtor
|
ObjectArrayFIFOQueue(int capacity)
Constructor with a Min Capacity
|
ObjectArrayFIFOQueue(T[] values)
Constructor using a initial array
|
ObjectArrayFIFOQueue(T[] values,
int size)
Constructor using a initial array
|
ObjectArrayFIFOQueue(T[] values,
int offset,
int size)
Constructor using a initial array
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
clears all elements within the PriorityQueue,
this does not resize the backing arrays
|
void |
clearAndTrim(int size)
Trims the collection down to the requested size and clears all elements while doing so
|
java.util.Comparator<? super T> |
comparator() |
ObjectArrayFIFOQueue<T> |
copy()
A Function that does a shallow clone of the PriorityQueue itself.
|
int |
count(java.util.function.Predicate<T> filter)
Helper function to reduce stream usage that allows to count the valid elements.
|
T |
dequeue()
Method to extract a element from the PriorityQueue
|
T |
dequeueLast()
A Method to remove a element from the last place instead of the first
|
void |
enqueue(T e)
Method to insert a element into the PriorityQueue
|
void |
enqueueFirst(T e)
Method to insert a element into the first Index instead of the last.
|
T |
findFirst(java.util.function.Predicate<T> filter)
Helper function to reduce stream usage that allows to filter for the first match.
|
void |
forEach(java.util.function.Consumer<? super T> action) |
<E> void |
forEach(E input,
ObjectObjectConsumer<E,T> action)
Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
void |
forEachIndexed(IntObjectConsumer<T> action)
A Indexed forEach implementation that allows you to keep track of how many elements were already iterated over.
|
ObjectIterator<T> |
iterator()
Returns an iterator over elements of type
T. |
boolean |
matchesAll(java.util.function.Predicate<T> filter)
Helper function to reduce stream usage that allows to filter for all matches.
|
boolean |
matchesAny(java.util.function.Predicate<T> filter)
Helper function to reduce stream usage that allows to filter for any matches.
|
boolean |
matchesNone(java.util.function.Predicate<T> filter)
Helper function to reduce stream usage that allows to filter for no matches.
|
void |
onChanged()
Allows to notify the Queue to be revalidate its data
|
T |
peek(int index)
Peeking function to see whats inside the queue.
|
<E> E |
reduce(E identity,
java.util.function.BiFunction<E,T,E> operator)
Performs a reduction on the
elements of this Iterable
|
T |
reduce(ObjectObjectUnaryOperator<T,T> operator)
Performs a reduction on the
elements of this Iterable
|
boolean |
removeFirst(T e)
Removes the first found element in the queue
|
boolean |
removeLast(T e)
Removes the last found element in the queue
|
int |
size() |
<E> E[] |
toArray(E[] input)
A method to drop the contents of the Queue without clearing the queue
|
boolean |
trim(int size)
Trims the original collection down to the size of the current elements or the requested size depending which is bigger
|
equals, hashCode, toStringenqueueAllFirst, enqueueAllFirst, enqueueAllFirst, enqueueAllFirst, enqueueAllFirst, last, synchronizeQueue, synchronizeQueueenqueueAll, enqueueAll, enqueueAll, enqueueAll, enqueueAll, first, isEmpty, toArray, toArrayarrayflatMap, asAsync, distinct, filter, flatMap, limit, map, peek, pour, pourAsList, pourAsSet, repeat, sorted, spliteratorclearAndTrim, trimpublic static final int MIN_CAPACITY
public ObjectArrayFIFOQueue(T[] values)
values - the Array that should be usedpublic ObjectArrayFIFOQueue(T[] values, int size)
values - the Array that should be usedsize - the amount of elements that are in the initial arrayjava.lang.IllegalStateException - if values is smaller then sizepublic ObjectArrayFIFOQueue(T[] values, int offset, int size)
values - the Array that should be usedoffset - where to begin in the initial arraysize - the amount of elements that are in the initial arrayjava.lang.IllegalStateException - if values is smaller then sizepublic ObjectArrayFIFOQueue(int capacity)
capacity - the initial capacity of the backing arrayjava.lang.IllegalStateException - if the initial size is smaller 0public ObjectArrayFIFOQueue()
public ObjectIterator<T> iterator()
ObjectIterableT.iterator in interface java.lang.Iterable<T>iterator in interface ObjectIterable<T>iterator in interface ObjectPriorityQueue<T>public int size()
size in interface ObjectPriorityQueue<T>public void clear()
ObjectPriorityQueueclear in interface ObjectPriorityQueue<T>public void enqueue(T e)
ObjectPriorityQueueenqueue in interface ObjectPriorityQueue<T>e - the element that should be insertedpublic void enqueueFirst(T e)
ObjectPriorityDequeueenqueueFirst in interface ObjectPriorityDequeue<T>e - the element that should be inserted into the first placepublic T dequeue()
ObjectPriorityQueuedequeue in interface ObjectPriorityQueue<T>public T dequeueLast()
ObjectPriorityDequeuedequeueLast in interface ObjectPriorityDequeue<T>public T peek(int index)
ObjectPriorityQueuepeek in interface ObjectPriorityQueue<T>index - of the element that is requested to be viewed.public boolean removeFirst(T e)
ObjectPriorityQueueremoveFirst in interface ObjectPriorityQueue<T>e - the element that should be removedpublic boolean removeLast(T e)
ObjectPriorityQueueremoveLast in interface ObjectPriorityQueue<T>e - the element that should be removedpublic void onChanged()
ObjectPriorityQueueonChanged in interface ObjectPriorityQueue<T>public ObjectArrayFIFOQueue<T> copy()
ObjectPriorityQueuecopy in interface ObjectPriorityDequeue<T>copy in interface ObjectPriorityQueue<T>public java.util.Comparator<? super T> comparator()
comparator in interface ObjectPriorityQueue<T>public void forEach(java.util.function.Consumer<? super T> action)
forEach in interface java.lang.Iterable<T>public void forEachIndexed(IntObjectConsumer<T> action)
ObjectIterableforEachIndexed in interface ObjectIterable<T>action - The action to be performed for each elementpublic <E> void forEach(E input,
ObjectObjectConsumer<E,T> action)
ObjectIterableforEach in interface ObjectIterable<T>E - the generic type of the Objectinput - the object that should be includedaction - The action to be performed for each elementpublic boolean matchesAny(java.util.function.Predicate<T> filter)
ObjectIterablematchesAny in interface ObjectIterable<T>filter - that should be appliedpublic boolean matchesNone(java.util.function.Predicate<T> filter)
ObjectIterablematchesNone in interface ObjectIterable<T>filter - that should be appliedpublic boolean matchesAll(java.util.function.Predicate<T> filter)
ObjectIterablematchesAll in interface ObjectIterable<T>filter - that should be appliedpublic T findFirst(java.util.function.Predicate<T> filter)
ObjectIterablefindFirst in interface ObjectIterable<T>filter - that should be appliedpublic <E> E reduce(E identity,
java.util.function.BiFunction<E,T,E> operator)
ObjectIterablereduce in interface ObjectIterable<T>E - the keyType of elements maintained by this Collectionidentity - the start valueoperator - the operation that should be appliedpublic T reduce(ObjectObjectUnaryOperator<T,T> operator)
ObjectIterablereduce in interface ObjectIterable<T>operator - the operation that should be appliedpublic int count(java.util.function.Predicate<T> filter)
ObjectIterablecount in interface ObjectIterable<T>filter - that should be appliedpublic boolean trim(int size)
ITrimmabletrim in interface ITrimmablesize - the requested trim size.public void clearAndTrim(int size)
clearAndTrim in interface ITrimmablesize - the amount of elements that should be allowedpublic <E> E[] toArray(E[] input)
ObjectPriorityQueuetoArray in interface ObjectPriorityQueue<T>E - the keyType of elements maintained by this Collectioninput - where the elements should be inserted to. If it does not fit then it creates a new appropiatly created array