Klasse LongAVLTreeSet

Alle implementierten Schnittstellen:
Iterable<Long>, Collection<Long>, NavigableSet<Long>, Set<Long>, SortedSet<Long>, LongCollection, LongIterable, LongNavigableSet, LongSet, LongSortedSet, ISizeProvider

public class LongAVLTreeSet extends AbstractLongSet implements LongNavigableSet
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

    • LongAVLTreeSet

      public LongAVLTreeSet()
      Default Constructor
    • LongAVLTreeSet

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

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

      public LongAVLTreeSet(long[] 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
    • LongAVLTreeSet

      public LongAVLTreeSet(long[] array, LongComparator 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
    • LongAVLTreeSet

      public LongAVLTreeSet(long[] array, int offset, int length, LongComparator 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
    • LongAVLTreeSet

      public LongAVLTreeSet(LongSortedSet 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
    • LongAVLTreeSet

      @Deprecated public LongAVLTreeSet(Collection<? extends Long> 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
    • LongAVLTreeSet

      @Deprecated public LongAVLTreeSet(Collection<? extends Long> collection, LongComparator 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
    • LongAVLTreeSet

      public LongAVLTreeSet(LongCollection 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
    • LongAVLTreeSet

      public LongAVLTreeSet(LongCollection collection, LongComparator 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
    • LongAVLTreeSet

      public LongAVLTreeSet(Iterator<Long> 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
    • LongAVLTreeSet

      public LongAVLTreeSet(Iterator<Long> iterator, LongComparator 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
    • LongAVLTreeSet

      public LongAVLTreeSet(LongIterator 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
    • LongAVLTreeSet

      public LongAVLTreeSet(LongIterator iterator, LongComparator 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(long value)
      Beschreibung aus Schnittstelle kopiert: LongNavigableSet
      A Helper method to set the max value for SubSets. (Default: long.MIN_VALUE)
      Angegeben von:
      setDefaultMaxValue in Schnittstelle LongNavigableSet
      Parameter:
      value - the new max value
    • getDefaultMaxValue

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

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

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

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

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

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

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

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

      public Long lower(Long e)
      Angegeben von:
      lower in Schnittstelle LongNavigableSet
      Angegeben von:
      lower in Schnittstelle NavigableSet<Long>
    • floor

      public Long floor(Long e)
      Angegeben von:
      floor in Schnittstelle LongNavigableSet
      Angegeben von:
      floor in Schnittstelle NavigableSet<Long>
    • higher

      public Long higher(Long e)
      Angegeben von:
      higher in Schnittstelle LongNavigableSet
      Angegeben von:
      higher in Schnittstelle NavigableSet<Long>
    • ceiling

      public Long ceiling(Long e)
      Angegeben von:
      ceiling in Schnittstelle LongNavigableSet
      Angegeben von:
      ceiling in Schnittstelle NavigableSet<Long>
    • forEach

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

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

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

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

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

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

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

      public boolean contains(long e)
      Beschreibung aus Klasse kopiert: AbstractLongCollection
      A Type-Specific implementation of contains. This implementation iterates over the elements and returns true if the value match.
      Angegeben von:
      contains in Schnittstelle LongCollection
      Setzt außer Kraft:
      contains in Klasse AbstractLongCollection
      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: AbstractLongCollection

      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<Long>
      Angegeben von:
      contains in Schnittstelle LongCollection
      Angegeben von:
      contains in Schnittstelle LongSet
      Angegeben von:
      contains in Schnittstelle Set<Long>
      Setzt außer Kraft:
      contains in Klasse AbstractLongCollection
    • firstLong

      public long firstLong()
      Beschreibung aus Schnittstelle kopiert: LongSortedSet
      A method to get the first element in the set
      Angegeben von:
      firstLong in Schnittstelle LongSortedSet
      Gibt zurück:
      first element in the set
    • lastLong

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

      public boolean remove(long o)
      Beschreibung aus Schnittstelle kopiert: LongSet
      A Type Specific remove function to reduce boxing/unboxing
      Angegeben von:
      remove in Schnittstelle LongSet
      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: AbstractLongCollection

      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<Long>
      Angegeben von:
      remove in Schnittstelle LongCollection
      Angegeben von:
      remove in Schnittstelle LongSet
      Angegeben von:
      remove in Schnittstelle Set<Long>
      Setzt außer Kraft:
      remove in Klasse AbstractLongCollection
    • pollFirstLong

      public long pollFirstLong()
      Beschreibung aus Schnittstelle kopiert: LongSortedSet
      A method to get and remove the first element in the set
      Angegeben von:
      pollFirstLong in Schnittstelle LongSortedSet
      Gibt zurück:
      first element in the set
    • pollLastLong

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

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

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

      public long[] toLongArray(long[] a)
      Beschreibung aus Klasse kopiert: AbstractLongCollection
      A Type-Specific implementation of toArray. This implementation iterates over all elements and unwraps them into primitive type.
      Angegeben von:
      toLongArray in Schnittstelle LongCollection
      Setzt außer Kraft:
      toLongArray in Klasse AbstractLongCollection
      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<Long>
      Angegeben von:
      toArray in Schnittstelle Set<Long>
      Setzt außer Kraft:
      toArray in Klasse AbstractCollection<Long>
    • toArray

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

      public LongAVLTreeSet copy()
      Beschreibung aus Schnittstelle kopiert: LongCollection
      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 LongCollection
      Angegeben von:
      copy in Schnittstelle LongNavigableSet
      Angegeben von:
      copy in Schnittstelle LongSet
      Angegeben von:
      copy in Schnittstelle LongSortedSet
      Setzt außer Kraft:
      copy in Klasse AbstractLongSet
      Gibt zurück:
      a Shallow Copy of the collection
    • comparator

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

      public LongBidirectionalIterator iterator()
      Beschreibung aus Schnittstelle kopiert: LongCollection
      Returns a Type-Specific Iterator to reduce (un)boxing
      Angegeben von:
      iterator in Schnittstelle Collection<Long>
      Angegeben von:
      iterator in Schnittstelle Iterable<Long>
      Angegeben von:
      iterator in Schnittstelle LongCollection
      Angegeben von:
      iterator in Schnittstelle LongIterable
      Angegeben von:
      iterator in Schnittstelle LongNavigableSet
      Angegeben von:
      iterator in Schnittstelle LongSet
      Angegeben von:
      iterator in Schnittstelle LongSortedSet
      Angegeben von:
      iterator in Schnittstelle NavigableSet<Long>
      Angegeben von:
      iterator in Schnittstelle Set<Long>
      Angegeben von:
      iterator in Klasse AbstractLongSet
      Gibt zurück:
      a iterator of the collection
      Siehe auch:
    • iterator

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

      public LongBidirectionalIterator descendingIterator()
      Angegeben von:
      descendingIterator in Schnittstelle LongNavigableSet
      Angegeben von:
      descendingIterator in Schnittstelle NavigableSet<Long>
      Gibt zurück:
      a Type Specific desendingIterator
    • subSet

      public LongNavigableSet subSet(long fromElement, boolean fromInclusive, long toElement, boolean toInclusive)
      Beschreibung aus Schnittstelle kopiert: LongNavigableSet
      A Type Specific SubSet method to reduce boxing/unboxing
      Angegeben von:
      subSet in Schnittstelle LongNavigableSet
      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 LongNavigableSet headSet(long toElement, boolean inclusive)
      Beschreibung aus Schnittstelle kopiert: LongNavigableSet
      A Type Specific HeadSet method to reduce boxing/unboxing
      Angegeben von:
      headSet in Schnittstelle LongNavigableSet
      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 LongNavigableSet tailSet(long fromElement, boolean inclusive)
      Beschreibung aus Schnittstelle kopiert: LongNavigableSet
      A Type Specific TailSet method to reduce boxing/unboxing
      Angegeben von:
      tailSet in Schnittstelle LongNavigableSet
      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 LongNavigableSet descendingSet()
      Angegeben von:
      descendingSet in Schnittstelle LongNavigableSet
      Angegeben von:
      descendingSet in Schnittstelle NavigableSet<Long>
      Gibt zurück:
      a Type Specific desendingSet