Klasse ShortAVLTreeSet

Alle implementierten Schnittstellen:
Iterable<Short>, Collection<Short>, NavigableSet<Short>, Set<Short>, SortedSet<Short>, ShortCollection, ShortIterable, ShortNavigableSet, ShortSet, ShortSortedSet, ISizeProvider

public class ShortAVLTreeSet extends AbstractShortSet implements ShortNavigableSet
A Simple Type Specific AVL TreeSet implementation that reduces boxing/unboxing. It is using a bit more memory then FastUtil, but it saves a lot of Performance on the Optimized removal and iteration logic. Which makes the implementation actually useable and does not get outperformed by Javas default implementation.
  • Konstruktordetails

    • ShortAVLTreeSet

      public ShortAVLTreeSet()
      Default Constructor
    • ShortAVLTreeSet

      public ShortAVLTreeSet(ShortComparator comp)
      Constructor that allows to define the sorter
      Parameter:
      comp - the function that decides how the tree is sorted, can be null
    • ShortAVLTreeSet

      public ShortAVLTreeSet(short[] array)
      Helper constructor that allow to create a set from an array
      Parameter:
      array - the elements that should be used
    • ShortAVLTreeSet

      public ShortAVLTreeSet(short[] array, int offset, int length)
      Helper constructor that allow to create a set from an array
      Parameter:
      array - the elements that should be used
      offset - the starting index within the array
      length - the amount of elements that are within the array
      Löst aus:
      IllegalStateException - if offset and length causes to step outside of the arrays range
    • ShortAVLTreeSet

      public ShortAVLTreeSet(short[] array, ShortComparator comp)
      Helper constructor that allow to create a set from an array
      Parameter:
      array - the elements that should be used
      comp - the sorter of the tree, can be null
    • ShortAVLTreeSet

      public ShortAVLTreeSet(short[] array, int offset, int length, ShortComparator comp)
      Helper constructor that allow to create a set from an array
      Parameter:
      array - the elements that should be used
      offset - the starting index within the array
      length - the amount of elements that are within the array
      comp - the sorter of the tree, can be null
      Löst aus:
      IllegalStateException - if offset and length causes to step outside of the arrays range
    • ShortAVLTreeSet

      public ShortAVLTreeSet(ShortSortedSet sortedSet)
      A Helper constructor that allows to create a Set with exactly the same values as the provided SortedSet.
      Parameter:
      sortedSet - the set the elements should be added to the TreeSet
      Note:
      this also includes the Comparator if present
    • ShortAVLTreeSet

      @Deprecated public ShortAVLTreeSet(Collection<? extends Short> collection)
      Veraltet.
      A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
      Parameter:
      collection - the set the elements should be added to the TreeSet
    • ShortAVLTreeSet

      @Deprecated public ShortAVLTreeSet(Collection<? extends Short> collection, ShortComparator comp)
      Veraltet.
      A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
      Parameter:
      collection - the set the elements should be added to the TreeSet
      comp - the sorter of the tree, can be null
    • ShortAVLTreeSet

      public ShortAVLTreeSet(ShortCollection collection)
      A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
      Parameter:
      collection - the set the elements should be added to the TreeSet
    • ShortAVLTreeSet

      public ShortAVLTreeSet(ShortCollection collection, ShortComparator comp)
      A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
      Parameter:
      collection - the set the elements should be added to the TreeSet
      comp - the sorter of the tree, can be null
    • ShortAVLTreeSet

      public ShortAVLTreeSet(Iterator<Short> iterator)
      A Helper constructor that allows to create a set from a iterator of an unknown size
      Parameter:
      iterator - the elements that should be added to the set
    • ShortAVLTreeSet

      public ShortAVLTreeSet(Iterator<Short> iterator, ShortComparator comp)
      A Helper constructor that allows to create a set from a iterator of an unknown size
      Parameter:
      iterator - the elements that should be added to the set
      comp - the sorter of the tree, can be null
    • ShortAVLTreeSet

      public ShortAVLTreeSet(ShortIterator iterator)
      A Helper constructor that allows to create a set from a iterator of an unknown size
      Parameter:
      iterator - the elements that should be added to the set
    • ShortAVLTreeSet

      public ShortAVLTreeSet(ShortIterator iterator, ShortComparator comp)
      A Helper constructor that allows to create a set from a iterator of an unknown size
      Parameter:
      iterator - the elements that should be added to the set
      comp - the sorter of the tree, can be null
  • Methodendetails

    • setDefaultMaxValue

      public void setDefaultMaxValue(short value)
      Beschreibung aus Schnittstelle kopiert: ShortNavigableSet
      A Helper method to set the max value for SubSets. (Default: short.MIN_VALUE)
      Angegeben von:
      setDefaultMaxValue in Schnittstelle ShortNavigableSet
      Parameter:
      value - the new max value
    • getDefaultMaxValue

      public short getDefaultMaxValue()
      Beschreibung aus Schnittstelle kopiert: ShortNavigableSet
      A Helper method to get the max value for SubSets.
      Angegeben von:
      getDefaultMaxValue in Schnittstelle ShortNavigableSet
      Gibt zurück:
      the default max value.
    • setDefaultMinValue

      public void setDefaultMinValue(short value)
      Beschreibung aus Schnittstelle kopiert: ShortNavigableSet
      A Helper method to set the min value for SubSets. (Default: short.MAX_VALUE)
      Angegeben von:
      setDefaultMinValue in Schnittstelle ShortNavigableSet
      Parameter:
      value - the new min value
    • getDefaultMinValue

      public short getDefaultMinValue()
      Beschreibung aus Schnittstelle kopiert: ShortNavigableSet
      A Helper method to get the min value for SubSets.
      Angegeben von:
      getDefaultMinValue in Schnittstelle ShortNavigableSet
      Gibt zurück:
      the default min value.
    • add

      public boolean add(short o)
      Beschreibung aus Schnittstelle kopiert: ShortCollection
      A Type-Specific add function to reduce (un)boxing
      Angegeben von:
      add in Schnittstelle ShortCollection
      Parameter:
      o - the element that should be added
      Gibt zurück:
      true if the element was added to the collection
    • lower

      public short lower(short e)
      Beschreibung aus Schnittstelle kopiert: ShortNavigableSet
      A Type Specific lower method to reduce boxing/unboxing.
      Angegeben von:
      lower in Schnittstelle ShortNavigableSet
      Parameter:
      e - that should be compared with.
      Gibt zurück:
      the greatest lower key that can be found
    • floor

      public short floor(short e)
      Beschreibung aus Schnittstelle kopiert: ShortNavigableSet
      A Type Specific floor method to reduce boxing/unboxing.
      Angegeben von:
      floor in Schnittstelle ShortNavigableSet
      Parameter:
      e - that should be compared with.
      Gibt zurück:
      the greatest lower or equal key that can be found
    • higher

      public short higher(short e)
      Beschreibung aus Schnittstelle kopiert: ShortNavigableSet
      A Type Specific higher method to reduce boxing/unboxing.
      Angegeben von:
      higher in Schnittstelle ShortNavigableSet
      Parameter:
      e - that should be compared with.
      Gibt zurück:
      the lowest higher key that can be found
    • ceiling

      public short ceiling(short e)
      Beschreibung aus Schnittstelle kopiert: ShortNavigableSet
      A Type Specific ceiling method to reduce boxing/unboxing.
      Angegeben von:
      ceiling in Schnittstelle ShortNavigableSet
      Parameter:
      e - that should be compared with.
      Gibt zurück:
      the lowest higher or equal key that can be found
    • lower

      public Short lower(Short e)
      Angegeben von:
      lower in Schnittstelle NavigableSet<Short>
      Angegeben von:
      lower in Schnittstelle ShortNavigableSet
    • floor

      public Short floor(Short e)
      Angegeben von:
      floor in Schnittstelle NavigableSet<Short>
      Angegeben von:
      floor in Schnittstelle ShortNavigableSet
    • higher

      public Short higher(Short e)
      Angegeben von:
      higher in Schnittstelle NavigableSet<Short>
      Angegeben von:
      higher in Schnittstelle ShortNavigableSet
    • ceiling

      public Short ceiling(Short e)
      Angegeben von:
      ceiling in Schnittstelle NavigableSet<Short>
      Angegeben von:
      ceiling in Schnittstelle ShortNavigableSet
    • forEach

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

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

      public <E> void forEach(E input, ObjectShortConsumer<E> action)
      Beschreibung aus Schnittstelle kopiert: ShortIterable
      Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
      Angegeben von:
      forEach in Schnittstelle ShortIterable
      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(ShortPredicate filter)
      Beschreibung aus Schnittstelle kopiert: ShortIterable
      Helper function to reduce stream usage that allows to filter for any matches.
      Angegeben von:
      matchesAny in Schnittstelle ShortIterable
      Parameter:
      filter - that should be applied
      Gibt zurück:
      true if any matches were found
    • matchesNone

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

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

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

      public short reduce(short identity, ShortShortUnaryOperator operator)
      Beschreibung aus Schnittstelle kopiert: ShortIterable
      Performs a reduction on the elements of this Iterable
      Angegeben von:
      reduce in Schnittstelle ShortIterable
      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 short reduce(ShortShortUnaryOperator operator)
      Beschreibung aus Schnittstelle kopiert: ShortIterable
      Performs a reduction on the elements of this Iterable
      Angegeben von:
      reduce in Schnittstelle ShortIterable
      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(ShortPredicate filter)
      Beschreibung aus Schnittstelle kopiert: ShortIterable
      Helper function to reduce stream usage that allows to count the valid elements.
      Angegeben von:
      count in Schnittstelle ShortIterable
      Parameter:
      filter - that should be applied
      Gibt zurück:
      the amount of Valid Elements
    • contains

      public boolean contains(short e)
      Beschreibung aus Klasse kopiert: AbstractShortCollection
      A Type-Specific implementation of contains. This implementation iterates over the elements and returns true if the value match.
      Angegeben von:
      contains in Schnittstelle ShortCollection
      Setzt außer Kraft:
      contains in Klasse AbstractShortCollection
      Parameter:
      e - the element that should be searched for.
      Gibt zurück:
      true if the value was found.
    • contains

      public boolean contains(Object e)
      Beschreibung aus Klasse kopiert: AbstractShortCollection

      This default implementation delegates to the corresponding type-specific function.

      This default implementation delegates to the corresponding type-specific function.

      Angegeben von:
      contains in Schnittstelle Collection<Short>
      Angegeben von:
      contains in Schnittstelle Set<Short>
      Angegeben von:
      contains in Schnittstelle ShortCollection
      Angegeben von:
      contains in Schnittstelle ShortSet
      Setzt außer Kraft:
      contains in Klasse AbstractShortCollection
    • firstShort

      public short firstShort()
      Beschreibung aus Schnittstelle kopiert: ShortSortedSet
      A method to get the first element in the set
      Angegeben von:
      firstShort in Schnittstelle ShortSortedSet
      Gibt zurück:
      first element in the set
    • lastShort

      public short lastShort()
      Beschreibung aus Schnittstelle kopiert: ShortSortedSet
      A method to get the last element in the set
      Angegeben von:
      lastShort in Schnittstelle ShortSortedSet
      Gibt zurück:
      last element in the set
    • remove

      public boolean remove(short o)
      Beschreibung aus Schnittstelle kopiert: ShortSet
      A Type Specific remove function to reduce boxing/unboxing
      Angegeben von:
      remove in Schnittstelle ShortSet
      Parameter:
      o - the element that should be removed
      Gibt zurück:
      true if the element was removed
    • remove

      public boolean remove(Object o)
      Beschreibung aus Klasse kopiert: AbstractShortCollection

      This default implementation delegates to the corresponding type-specific function.

      This default implementation delegates to the corresponding type-specific function.

      Angegeben von:
      remove in Schnittstelle Collection<Short>
      Angegeben von:
      remove in Schnittstelle Set<Short>
      Angegeben von:
      remove in Schnittstelle ShortCollection
      Angegeben von:
      remove in Schnittstelle ShortSet
      Setzt außer Kraft:
      remove in Klasse AbstractShortCollection
    • pollFirstShort

      public short pollFirstShort()
      Beschreibung aus Schnittstelle kopiert: ShortSortedSet
      A method to get and remove the first element in the set
      Angegeben von:
      pollFirstShort in Schnittstelle ShortSortedSet
      Gibt zurück:
      first element in the set
    • pollLastShort

      public short pollLastShort()
      Beschreibung aus Schnittstelle kopiert: ShortSortedSet
      A method to get and remove the last element in the set
      Angegeben von:
      pollLastShort in Schnittstelle ShortSortedSet
      Gibt zurück:
      last element in the set
    • size

      public int size()
      Angegeben von:
      size in Schnittstelle Collection<Short>
      Angegeben von:
      size in Schnittstelle ISizeProvider
      Angegeben von:
      size in Schnittstelle Set<Short>
      Angegeben von:
      size in Klasse AbstractCollection<Short>
      Gibt zurück:
      the size of the implementing Collection
    • clear

      public void clear()
      Angegeben von:
      clear in Schnittstelle Collection<Short>
      Angegeben von:
      clear in Schnittstelle Set<Short>
      Setzt außer Kraft:
      clear in Klasse AbstractCollection<Short>
    • toShortArray

      public short[] toShortArray(short[] a)
      Beschreibung aus Klasse kopiert: AbstractShortCollection
      A Type-Specific implementation of toArray. This implementation iterates over all elements and unwraps them into primitive type.
      Angegeben von:
      toShortArray in Schnittstelle ShortCollection
      Setzt außer Kraft:
      toShortArray in Klasse AbstractShortCollection
      Parameter:
      a - array that the elements should be injected to. If null or to small a new array with the right size is created
      Gibt zurück:
      an array containing all of the elements in this collection
      Siehe auch:
    • toArray

      @Deprecated public Object[] toArray()
      Veraltet.
      Angegeben von:
      toArray in Schnittstelle Collection<Short>
      Angegeben von:
      toArray in Schnittstelle Set<Short>
      Setzt außer Kraft:
      toArray in Klasse AbstractCollection<Short>
    • toArray

      @Deprecated public <E> E[] toArray(E[] a)
      Veraltet.
      Angegeben von:
      toArray in Schnittstelle Collection<Short>
      Angegeben von:
      toArray in Schnittstelle Set<Short>
      Setzt außer Kraft:
      toArray in Klasse AbstractCollection<Short>
    • copy

      public ShortAVLTreeSet copy()
      Beschreibung aus Schnittstelle kopiert: ShortCollection
      A Function that does a shallow clone of the Collection itself. This function is more optimized then a copy constructor since the Collection does not have to be unsorted/resorted. It can be compared to Cloneable but with less exception risk
      Angegeben von:
      copy in Schnittstelle ShortCollection
      Angegeben von:
      copy in Schnittstelle ShortNavigableSet
      Angegeben von:
      copy in Schnittstelle ShortSet
      Angegeben von:
      copy in Schnittstelle ShortSortedSet
      Setzt außer Kraft:
      copy in Klasse AbstractShortSet
      Gibt zurück:
      a Shallow Copy of the collection
    • comparator

      public ShortComparator comparator()
      Beschreibung aus Schnittstelle kopiert: ShortSortedSet
      A Type Specific Comparator method
      Angegeben von:
      comparator in Schnittstelle ShortSortedSet
      Angegeben von:
      comparator in Schnittstelle SortedSet<Short>
      Gibt zurück:
      the type specific comparator
    • iterator

      public ShortBidirectionalIterator iterator()
      Beschreibung aus Schnittstelle kopiert: ShortCollection
      Returns a Type-Specific Iterator to reduce (un)boxing
      Angegeben von:
      iterator in Schnittstelle Collection<Short>
      Angegeben von:
      iterator in Schnittstelle Iterable<Short>
      Angegeben von:
      iterator in Schnittstelle NavigableSet<Short>
      Angegeben von:
      iterator in Schnittstelle Set<Short>
      Angegeben von:
      iterator in Schnittstelle ShortCollection
      Angegeben von:
      iterator in Schnittstelle ShortIterable
      Angegeben von:
      iterator in Schnittstelle ShortNavigableSet
      Angegeben von:
      iterator in Schnittstelle ShortSet
      Angegeben von:
      iterator in Schnittstelle ShortSortedSet
      Angegeben von:
      iterator in Klasse AbstractShortSet
      Gibt zurück:
      a iterator of the collection
      Siehe auch:
    • iterator

      public ShortBidirectionalIterator iterator(short fromElement)
      Beschreibung aus Schnittstelle kopiert: ShortSortedSet
      A type Specific Iterator starting from a given key
      Angegeben von:
      iterator in Schnittstelle ShortSortedSet
      Parameter:
      fromElement - the element the iterator should start from
      Gibt zurück:
      a iterator starting from the given element
    • descendingIterator

      public ShortBidirectionalIterator descendingIterator()
      Angegeben von:
      descendingIterator in Schnittstelle NavigableSet<Short>
      Angegeben von:
      descendingIterator in Schnittstelle ShortNavigableSet
      Gibt zurück:
      a Type Specific desendingIterator
    • subSet

      public ShortNavigableSet subSet(short fromElement, boolean fromInclusive, short toElement, boolean toInclusive)
      Beschreibung aus Schnittstelle kopiert: ShortNavigableSet
      A Type Specific SubSet method to reduce boxing/unboxing
      Angegeben von:
      subSet in Schnittstelle ShortNavigableSet
      Parameter:
      fromElement - where the SubSet should start
      fromInclusive - if the fromElement is inclusive or not
      toElement - where the SubSet should end
      toInclusive - if the toElement is inclusive or not
      Gibt zurück:
      a SubSet that is within the range of the desired range
    • headSet

      public ShortNavigableSet headSet(short toElement, boolean inclusive)
      Beschreibung aus Schnittstelle kopiert: ShortNavigableSet
      A Type Specific HeadSet method to reduce boxing/unboxing
      Angegeben von:
      headSet in Schnittstelle ShortNavigableSet
      Parameter:
      toElement - where the HeadSet should end
      inclusive - if the toElement is inclusive or not
      Gibt zurück:
      a HeadSet that is within the range of the desired range
    • tailSet

      public ShortNavigableSet tailSet(short fromElement, boolean inclusive)
      Beschreibung aus Schnittstelle kopiert: ShortNavigableSet
      A Type Specific TailSet method to reduce boxing/unboxing
      Angegeben von:
      tailSet in Schnittstelle ShortNavigableSet
      Parameter:
      fromElement - where the TailSet should start
      inclusive - if the fromElement is inclusive or not
      Gibt zurück:
      a TailSet that is within the range of the desired range
    • descendingSet

      public ShortNavigableSet descendingSet()
      Angegeben von:
      descendingSet in Schnittstelle NavigableSet<Short>
      Angegeben von:
      descendingSet in Schnittstelle ShortNavigableSet
      Gibt zurück:
      a Type Specific desendingSet