Klasse IntAVLTreeSet

Alle implementierten Schnittstellen:
Iterable<Integer>, Collection<Integer>, NavigableSet<Integer>, Set<Integer>, SortedSet<Integer>, IntCollection, IntIterable, IntNavigableSet, IntSet, IntSortedSet, ISizeProvider

public class IntAVLTreeSet extends AbstractIntSet implements IntNavigableSet
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

    • IntAVLTreeSet

      public IntAVLTreeSet()
      Default Constructor
    • IntAVLTreeSet

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

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

      public IntAVLTreeSet(int[] 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
    • IntAVLTreeSet

      public IntAVLTreeSet(int[] array, IntComparator 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
    • IntAVLTreeSet

      public IntAVLTreeSet(int[] array, int offset, int length, IntComparator 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
    • IntAVLTreeSet

      public IntAVLTreeSet(IntSortedSet 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
    • IntAVLTreeSet

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

      @Deprecated public IntAVLTreeSet(Collection<? extends Integer> collection, IntComparator 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
    • IntAVLTreeSet

      public IntAVLTreeSet(IntCollection 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
    • IntAVLTreeSet

      public IntAVLTreeSet(IntCollection collection, IntComparator 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
    • IntAVLTreeSet

      public IntAVLTreeSet(Iterator<Integer> 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
    • IntAVLTreeSet

      public IntAVLTreeSet(Iterator<Integer> iterator, IntComparator 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
    • IntAVLTreeSet

      public IntAVLTreeSet(IntIterator 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
    • IntAVLTreeSet

      public IntAVLTreeSet(IntIterator iterator, IntComparator 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(int value)
      Beschreibung aus Schnittstelle kopiert: IntNavigableSet
      A Helper method to set the max value for SubSets. (Default: int.MIN_VALUE)
      Angegeben von:
      setDefaultMaxValue in Schnittstelle IntNavigableSet
      Parameter:
      value - the new max value
    • getDefaultMaxValue

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

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

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

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

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

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

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

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

      public Integer lower(Integer e)
      Angegeben von:
      lower in Schnittstelle IntNavigableSet
      Angegeben von:
      lower in Schnittstelle NavigableSet<Integer>
    • floor

      public Integer floor(Integer e)
      Angegeben von:
      floor in Schnittstelle IntNavigableSet
      Angegeben von:
      floor in Schnittstelle NavigableSet<Integer>
    • higher

      public Integer higher(Integer e)
      Angegeben von:
      higher in Schnittstelle IntNavigableSet
      Angegeben von:
      higher in Schnittstelle NavigableSet<Integer>
    • ceiling

      public Integer ceiling(Integer e)
      Angegeben von:
      ceiling in Schnittstelle IntNavigableSet
      Angegeben von:
      ceiling in Schnittstelle NavigableSet<Integer>
    • forEach

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

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

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

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

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

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

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

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

      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<Integer>
      Angegeben von:
      contains in Schnittstelle IntCollection
      Angegeben von:
      contains in Schnittstelle IntSet
      Angegeben von:
      contains in Schnittstelle Set<Integer>
      Setzt außer Kraft:
      contains in Klasse AbstractIntCollection
    • firstInt

      public int firstInt()
      Beschreibung aus Schnittstelle kopiert: IntSortedSet
      A method to get the first element in the set
      Angegeben von:
      firstInt in Schnittstelle IntSortedSet
      Gibt zurück:
      first element in the set
    • lastInt

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

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

      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<Integer>
      Angegeben von:
      remove in Schnittstelle IntCollection
      Angegeben von:
      remove in Schnittstelle IntSet
      Angegeben von:
      remove in Schnittstelle Set<Integer>
      Setzt außer Kraft:
      remove in Klasse AbstractIntCollection
    • pollFirstInt

      public int pollFirstInt()
      Beschreibung aus Schnittstelle kopiert: IntSortedSet
      A method to get and remove the first element in the set
      Angegeben von:
      pollFirstInt in Schnittstelle IntSortedSet
      Gibt zurück:
      first element in the set
    • pollLastInt

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

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

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

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

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

      public IntAVLTreeSet copy()
      Beschreibung aus Schnittstelle kopiert: IntCollection
      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 IntCollection
      Angegeben von:
      copy in Schnittstelle IntNavigableSet
      Angegeben von:
      copy in Schnittstelle IntSet
      Angegeben von:
      copy in Schnittstelle IntSortedSet
      Setzt außer Kraft:
      copy in Klasse AbstractIntSet
      Gibt zurück:
      a Shallow Copy of the collection
    • comparator

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

      public IntBidirectionalIterator iterator()
      Beschreibung aus Schnittstelle kopiert: IntCollection
      Returns a Type-Specific Iterator to reduce (un)boxing
      Angegeben von:
      iterator in Schnittstelle Collection<Integer>
      Angegeben von:
      iterator in Schnittstelle IntCollection
      Angegeben von:
      iterator in Schnittstelle IntIterable
      Angegeben von:
      iterator in Schnittstelle IntNavigableSet
      Angegeben von:
      iterator in Schnittstelle IntSet
      Angegeben von:
      iterator in Schnittstelle IntSortedSet
      Angegeben von:
      iterator in Schnittstelle Iterable<Integer>
      Angegeben von:
      iterator in Schnittstelle NavigableSet<Integer>
      Angegeben von:
      iterator in Schnittstelle Set<Integer>
      Angegeben von:
      iterator in Klasse AbstractIntSet
      Gibt zurück:
      a iterator of the collection
      Siehe auch:
    • iterator

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

      public IntBidirectionalIterator descendingIterator()
      Angegeben von:
      descendingIterator in Schnittstelle IntNavigableSet
      Angegeben von:
      descendingIterator in Schnittstelle NavigableSet<Integer>
      Gibt zurück:
      a Type Specific desendingIterator
    • subSet

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