Klasse FloatArrayFIFOQueue

java.lang.Object
speiger.src.collections.floats.queues.AbstractFloatPriorityQueue
speiger.src.collections.floats.queues.FloatArrayFIFOQueue
Alle implementierten Schnittstellen:
Iterable<Float>, FloatIterable, FloatPriorityDequeue, FloatPriorityQueue, ITrimmable

public class FloatArrayFIFOQueue extends AbstractFloatPriorityQueue implements FloatPriorityDequeue, 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.
  • Felddetails

    • MIN_CAPACITY

      public static final int MIN_CAPACITY
      The Minimum Capacity that is allowed
      Siehe auch:
  • Konstruktordetails

    • FloatArrayFIFOQueue

      public FloatArrayFIFOQueue(float[] values)
      Constructor using a initial array
      Parameter:
      values - the Array that should be used
    • FloatArrayFIFOQueue

      public FloatArrayFIFOQueue(float[] values, int size)
      Constructor using a initial array
      Parameter:
      values - the Array that should be used
      size - the amount of elements that are in the initial array
      Löst aus:
      IllegalStateException - if values is smaller then size
    • FloatArrayFIFOQueue

      public FloatArrayFIFOQueue(float[] values, int offset, int size)
      Constructor using a initial array
      Parameter:
      values - the Array that should be used
      offset - where to begin in the initial array
      size - the amount of elements that are in the initial array
      Löst aus:
      IllegalStateException - if values is smaller then size
    • FloatArrayFIFOQueue

      public FloatArrayFIFOQueue(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
    • FloatArrayFIFOQueue

      public FloatArrayFIFOQueue()
      Default Construtor
  • Methodendetails

    • iterator

      public FloatIterator iterator()
      Beschreibung aus Schnittstelle kopiert: FloatIterable
      Returns an iterator over elements of type T.
      Angegeben von:
      iterator in Schnittstelle FloatIterable
      Angegeben von:
      iterator in Schnittstelle Iterable<Float>
      Gibt zurück:
      an Iterator.
    • size

      public int size()
      Angegeben von:
      size in Schnittstelle FloatPriorityQueue
      Gibt zurück:
      the amount of elements that are stored in the PriorityQueue
    • clear

      public void clear()
      Beschreibung aus Schnittstelle kopiert: FloatPriorityQueue
      clears all elements within the PriorityQueue, this does not resize the backing arrays
      Angegeben von:
      clear in Schnittstelle FloatPriorityQueue
    • enqueue

      public void enqueue(float e)
      Beschreibung aus Schnittstelle kopiert: FloatPriorityQueue
      Method to insert a element into the PriorityQueue
      Angegeben von:
      enqueue in Schnittstelle FloatPriorityQueue
      Parameter:
      e - the element that should be inserted
    • enqueueFirst

      public void enqueueFirst(float e)
      Beschreibung aus Schnittstelle kopiert: FloatPriorityDequeue
      Method to insert a element into the first Index instead of the last.
      Angegeben von:
      enqueueFirst in Schnittstelle FloatPriorityDequeue
      Parameter:
      e - the element that should be inserted into the first place
    • dequeue

      public float dequeue()
      Beschreibung aus Schnittstelle kopiert: FloatPriorityQueue
      Method to extract a element from the PriorityQueue
      Angegeben von:
      dequeue in Schnittstelle FloatPriorityQueue
      Gibt zurück:
      a element from the Queue
    • dequeueLast

      public float dequeueLast()
      Beschreibung aus Schnittstelle kopiert: FloatPriorityDequeue
      A Method to remove a element from the last place instead of the first
      Angegeben von:
      dequeueLast in Schnittstelle FloatPriorityDequeue
      Gibt zurück:
      the last element inserted
    • peek

      public float peek(int index)
      Beschreibung aus Schnittstelle kopiert: FloatPriorityQueue
      Peeking function to see whats inside the queue.
      Angegeben von:
      peek in Schnittstelle FloatPriorityQueue
      Parameter:
      index - of the element that is requested to be viewed.
      Gibt zurück:
      the element that is requested
    • contains

      public boolean contains(float e)
      Beschreibung aus Schnittstelle kopiert: FloatPriorityQueue
      Method to find out if a element is part of the queue
      Angegeben von:
      contains in Schnittstelle FloatPriorityQueue
      Parameter:
      e - the element that is searched for
      Gibt zurück:
      true if the element is in the queue
    • removeFirst

      public boolean removeFirst(float e)
      Beschreibung aus Schnittstelle kopiert: FloatPriorityQueue
      Removes the first found element in the queue
      Angegeben von:
      removeFirst in Schnittstelle FloatPriorityQueue
      Parameter:
      e - the element that should be removed
      Gibt zurück:
      if a searched element was removed
    • removeLast

      public boolean removeLast(float e)
      Beschreibung aus Schnittstelle kopiert: FloatPriorityQueue
      Removes the last found element in the queue
      Angegeben von:
      removeLast in Schnittstelle FloatPriorityQueue
      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: FloatPriorityQueue
      Allows to notify the Queue to be revalidate its data
      Angegeben von:
      onChanged in Schnittstelle FloatPriorityQueue
    • copy

      public FloatArrayFIFOQueue copy()
      Beschreibung aus Schnittstelle kopiert: FloatPriorityQueue
      A 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:
      copy in Schnittstelle FloatPriorityDequeue
      Angegeben von:
      copy in Schnittstelle FloatPriorityQueue
      Gibt zurück:
      a Shallow Copy of the PriorityQueue
    • comparator

      public FloatComparator comparator()
      Angegeben von:
      comparator in Schnittstelle FloatPriorityQueue
      Gibt zurück:
      the sorter of the Queue, can be null
    • forEach

      public void forEach(FloatConsumer action)
      Beschreibung aus Schnittstelle kopiert: FloatIterable
      A Type Specific foreach function that reduces (un)boxing
      Angegeben von:
      forEach in Schnittstelle FloatIterable
      Parameter:
      action - The action to be performed for each element
      Siehe auch:
    • forEachIndexed

      public void forEachIndexed(IntFloatConsumer action)
      Beschreibung aus Schnittstelle kopiert: FloatIterable
      A Indexed forEach implementation that allows you to keep track of how many elements were already iterated over.
      Angegeben von:
      forEachIndexed in Schnittstelle FloatIterable
      Parameter:
      action - The action to be performed for each element
    • forEach

      public <E> void forEach(E input, ObjectFloatConsumer<E> action)
      Beschreibung aus Schnittstelle kopiert: FloatIterable
      Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
      Angegeben von:
      forEach in Schnittstelle FloatIterable
      Typparameter:
      E - the generic type of the Object
      Parameter:
      input - the object that should be included
      action - The action to be performed for each element
    • matchesAny

      public boolean matchesAny(FloatPredicate filter)
      Beschreibung aus Schnittstelle kopiert: FloatIterable
      Helper function to reduce stream usage that allows to filter for any matches.
      Angegeben von:
      matchesAny in Schnittstelle FloatIterable
      Parameter:
      filter - that should be applied
      Gibt zurück:
      true if any matches were found
    • matchesNone

      public boolean matchesNone(FloatPredicate filter)
      Beschreibung aus Schnittstelle kopiert: FloatIterable
      Helper function to reduce stream usage that allows to filter for no matches.
      Angegeben von:
      matchesNone in Schnittstelle FloatIterable
      Parameter:
      filter - that should be applied
      Gibt zurück:
      true if no matches were found
    • matchesAll

      public boolean matchesAll(FloatPredicate filter)
      Beschreibung aus Schnittstelle kopiert: FloatIterable
      Helper function to reduce stream usage that allows to filter for all matches.
      Angegeben von:
      matchesAll in Schnittstelle FloatIterable
      Parameter:
      filter - that should be applied
      Gibt zurück:
      true if all matches.
    • findFirst

      public float findFirst(FloatPredicate filter)
      Beschreibung aus Schnittstelle kopiert: FloatIterable
      Helper function to reduce stream usage that allows to filter for the first match.
      Angegeben von:
      findFirst in Schnittstelle FloatIterable
      Parameter:
      filter - that should be applied
      Gibt zurück:
      the found value or the null equivalent variant.
    • reduce

      public float reduce(float identity, FloatFloatUnaryOperator operator)
      Beschreibung aus Schnittstelle kopiert: FloatIterable
      Performs a reduction on the elements of this Iterable
      Angegeben von:
      reduce in Schnittstelle FloatIterable
      Parameter:
      identity - the start value
      operator - the operation that should be applied
      Gibt zurück:
      the reduction result, returns identity if nothing was found
    • reduce

      public float reduce(FloatFloatUnaryOperator operator)
      Beschreibung aus Schnittstelle kopiert: FloatIterable
      Performs a reduction on the elements of this Iterable
      Angegeben von:
      reduce in Schnittstelle FloatIterable
      Parameter:
      operator - the operation that should be applied
      Gibt zurück:
      the reduction result, returns null value if nothing was found
    • count

      public int count(FloatPredicate filter)
      Beschreibung aus Schnittstelle kopiert: FloatIterable
      Helper function to reduce stream usage that allows to count the valid elements.
      Angegeben von:
      count in Schnittstelle FloatIterable
      Parameter:
      filter - that should be applied
      Gibt zurück:
      the amount of Valid Elements
    • trim

      public boolean trim(int size)
      Beschreibung aus Schnittstelle kopiert: ITrimmable
      Trims the original collection down to the size of the current elements or the requested size depending which is bigger
      Angegeben von:
      trim in Schnittstelle ITrimmable
      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:
      clearAndTrim in Schnittstelle ITrimmable
      Parameter:
      size - the amount of elements that should be allowed
      Note:
      this will enforce minimum size of the collection itself
    • toFloatArray

      public float[] toFloatArray(float[] input)
      Beschreibung aus Schnittstelle kopiert: FloatPriorityQueue
      A method to drop the contents of the Queue without clearing the queue
      Angegeben von:
      toFloatArray in Schnittstelle FloatPriorityQueue
      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.