Klasse ByteRBTreeSet

Alle implementierten Schnittstellen:
Iterable<Byte>, Collection<Byte>, NavigableSet<Byte>, Set<Byte>, SortedSet<Byte>, ByteCollection, ByteIterable, ByteNavigableSet, ByteSet, ByteSortedSet, ISizeProvider

public class ByteRBTreeSet extends AbstractByteSet implements ByteNavigableSet
A Simple Type Specific RB 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

    • ByteRBTreeSet

      public ByteRBTreeSet()
      Default Constructor
    • ByteRBTreeSet

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

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

      public ByteRBTreeSet(byte[] 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
    • ByteRBTreeSet

      public ByteRBTreeSet(byte[] array, ByteComparator 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
    • ByteRBTreeSet

      public ByteRBTreeSet(byte[] array, int offset, int length, ByteComparator 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
    • ByteRBTreeSet

      public ByteRBTreeSet(ByteSortedSet 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
    • ByteRBTreeSet

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

      @Deprecated public ByteRBTreeSet(Collection<? extends Byte> collection, ByteComparator 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
    • ByteRBTreeSet

      public ByteRBTreeSet(ByteCollection 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
    • ByteRBTreeSet

      public ByteRBTreeSet(ByteCollection collection, ByteComparator 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
    • ByteRBTreeSet

      public ByteRBTreeSet(Iterator<Byte> 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
    • ByteRBTreeSet

      public ByteRBTreeSet(Iterator<Byte> iterator, ByteComparator 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
    • ByteRBTreeSet

      public ByteRBTreeSet(ByteIterator 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
    • ByteRBTreeSet

      public ByteRBTreeSet(ByteIterator iterator, ByteComparator 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(byte value)
      Beschreibung aus Schnittstelle kopiert: ByteNavigableSet
      A Helper method to set the max value for SubSets. (Default: byte.MIN_VALUE)
      Angegeben von:
      setDefaultMaxValue in Schnittstelle ByteNavigableSet
      Parameter:
      value - the new max value
    • getDefaultMaxValue

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

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

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

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

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

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

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

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

      public Byte lower(Byte e)
      Angegeben von:
      lower in Schnittstelle ByteNavigableSet
      Angegeben von:
      lower in Schnittstelle NavigableSet<Byte>
    • floor

      public Byte floor(Byte e)
      Angegeben von:
      floor in Schnittstelle ByteNavigableSet
      Angegeben von:
      floor in Schnittstelle NavigableSet<Byte>
    • higher

      public Byte higher(Byte e)
      Angegeben von:
      higher in Schnittstelle ByteNavigableSet
      Angegeben von:
      higher in Schnittstelle NavigableSet<Byte>
    • ceiling

      public Byte ceiling(Byte e)
      Angegeben von:
      ceiling in Schnittstelle ByteNavigableSet
      Angegeben von:
      ceiling in Schnittstelle NavigableSet<Byte>
    • forEach

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

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

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

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

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

      public byte reduce(byte identity, ByteByteUnaryOperator operator)
      Beschreibung aus Schnittstelle kopiert: ByteIterable
      Performs a reduction on the elements of this Iterable
      Angegeben von:
      reduce in Schnittstelle ByteIterable
      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 byte reduce(ByteByteUnaryOperator operator)
      Beschreibung aus Schnittstelle kopiert: ByteIterable
      Performs a reduction on the elements of this Iterable
      Angegeben von:
      reduce in Schnittstelle ByteIterable
      Parameter:
      operator - the operation that should be applied
      Gibt zurück:
      the reduction result, returns null value if nothing was found
    • findFirst

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

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

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

      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 ByteCollection
      Angegeben von:
      contains in Schnittstelle ByteSet
      Angegeben von:
      contains in Schnittstelle Collection<Byte>
      Angegeben von:
      contains in Schnittstelle Set<Byte>
      Setzt außer Kraft:
      contains in Klasse AbstractByteCollection
    • firstByte

      public byte firstByte()
      Beschreibung aus Schnittstelle kopiert: ByteSortedSet
      A method to get the first element in the set
      Angegeben von:
      firstByte in Schnittstelle ByteSortedSet
      Gibt zurück:
      first element in the set
    • lastByte

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

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

      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 ByteCollection
      Angegeben von:
      remove in Schnittstelle ByteSet
      Angegeben von:
      remove in Schnittstelle Collection<Byte>
      Angegeben von:
      remove in Schnittstelle Set<Byte>
      Setzt außer Kraft:
      remove in Klasse AbstractByteCollection
    • pollFirstByte

      public byte pollFirstByte()
      Beschreibung aus Schnittstelle kopiert: ByteSortedSet
      A method to get and remove the first element in the set
      Angegeben von:
      pollFirstByte in Schnittstelle ByteSortedSet
      Gibt zurück:
      first element in the set
    • pollLastByte

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

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

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

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

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

      public ByteRBTreeSet copy()
      Beschreibung aus Schnittstelle kopiert: ByteCollection
      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 ByteCollection
      Angegeben von:
      copy in Schnittstelle ByteNavigableSet
      Angegeben von:
      copy in Schnittstelle ByteSet
      Angegeben von:
      copy in Schnittstelle ByteSortedSet
      Setzt außer Kraft:
      copy in Klasse AbstractByteSet
      Gibt zurück:
      a Shallow Copy of the collection
    • comparator

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

      public ByteBidirectionalIterator iterator()
      Beschreibung aus Schnittstelle kopiert: ByteCollection
      Returns a Type-Specific Iterator to reduce (un)boxing
      Angegeben von:
      iterator in Schnittstelle ByteCollection
      Angegeben von:
      iterator in Schnittstelle ByteIterable
      Angegeben von:
      iterator in Schnittstelle ByteNavigableSet
      Angegeben von:
      iterator in Schnittstelle ByteSet
      Angegeben von:
      iterator in Schnittstelle ByteSortedSet
      Angegeben von:
      iterator in Schnittstelle Collection<Byte>
      Angegeben von:
      iterator in Schnittstelle Iterable<Byte>
      Angegeben von:
      iterator in Schnittstelle NavigableSet<Byte>
      Angegeben von:
      iterator in Schnittstelle Set<Byte>
      Angegeben von:
      iterator in Klasse AbstractByteSet
      Gibt zurück:
      a iterator of the collection
      Siehe auch:
    • iterator

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

      public ByteBidirectionalIterator descendingIterator()
      Angegeben von:
      descendingIterator in Schnittstelle ByteNavigableSet
      Angegeben von:
      descendingIterator in Schnittstelle NavigableSet<Byte>
      Gibt zurück:
      a Type Specific desendingIterator
    • subSet

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