Klasse CharRBTreeSet

Alle implementierten Schnittstellen:
Iterable<Character>, Collection<Character>, NavigableSet<Character>, Set<Character>, SortedSet<Character>, CharCollection, CharIterable, CharNavigableSet, CharSet, CharSortedSet, ISizeProvider

public class CharRBTreeSet extends AbstractCharSet implements CharNavigableSet
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

    • CharRBTreeSet

      public CharRBTreeSet()
      Default Constructor
    • CharRBTreeSet

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

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

      public CharRBTreeSet(char[] 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
    • CharRBTreeSet

      public CharRBTreeSet(char[] array, CharComparator 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
    • CharRBTreeSet

      public CharRBTreeSet(char[] array, int offset, int length, CharComparator 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
    • CharRBTreeSet

      public CharRBTreeSet(CharSortedSet 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
    • CharRBTreeSet

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

      @Deprecated public CharRBTreeSet(Collection<? extends Character> collection, CharComparator 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
    • CharRBTreeSet

      public CharRBTreeSet(CharCollection 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
    • CharRBTreeSet

      public CharRBTreeSet(CharCollection collection, CharComparator 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
    • CharRBTreeSet

      public CharRBTreeSet(Iterator<Character> 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
    • CharRBTreeSet

      public CharRBTreeSet(Iterator<Character> iterator, CharComparator 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
    • CharRBTreeSet

      public CharRBTreeSet(CharIterator 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
    • CharRBTreeSet

      public CharRBTreeSet(CharIterator iterator, CharComparator 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(char value)
      Beschreibung aus Schnittstelle kopiert: CharNavigableSet
      A Helper method to set the max value for SubSets. (Default: char.MIN_VALUE)
      Angegeben von:
      setDefaultMaxValue in Schnittstelle CharNavigableSet
      Parameter:
      value - the new max value
    • getDefaultMaxValue

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

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

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

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

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

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

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

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

      public Character lower(Character e)
      Angegeben von:
      lower in Schnittstelle CharNavigableSet
      Angegeben von:
      lower in Schnittstelle NavigableSet<Character>
    • floor

      public Character floor(Character e)
      Angegeben von:
      floor in Schnittstelle CharNavigableSet
      Angegeben von:
      floor in Schnittstelle NavigableSet<Character>
    • higher

      public Character higher(Character e)
      Angegeben von:
      higher in Schnittstelle CharNavigableSet
      Angegeben von:
      higher in Schnittstelle NavigableSet<Character>
    • ceiling

      public Character ceiling(Character e)
      Angegeben von:
      ceiling in Schnittstelle CharNavigableSet
      Angegeben von:
      ceiling in Schnittstelle NavigableSet<Character>
    • forEach

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

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

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

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

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

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

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

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

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

      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 CharCollection
      Angegeben von:
      contains in Schnittstelle CharSet
      Angegeben von:
      contains in Schnittstelle Collection<Character>
      Angegeben von:
      contains in Schnittstelle Set<Character>
      Setzt außer Kraft:
      contains in Klasse AbstractCharCollection
    • firstChar

      public char firstChar()
      Beschreibung aus Schnittstelle kopiert: CharSortedSet
      A method to get the first element in the set
      Angegeben von:
      firstChar in Schnittstelle CharSortedSet
      Gibt zurück:
      first element in the set
    • lastChar

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

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

      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 CharCollection
      Angegeben von:
      remove in Schnittstelle CharSet
      Angegeben von:
      remove in Schnittstelle Collection<Character>
      Angegeben von:
      remove in Schnittstelle Set<Character>
      Setzt außer Kraft:
      remove in Klasse AbstractCharCollection
    • pollFirstChar

      public char pollFirstChar()
      Beschreibung aus Schnittstelle kopiert: CharSortedSet
      A method to get and remove the first element in the set
      Angegeben von:
      pollFirstChar in Schnittstelle CharSortedSet
      Gibt zurück:
      first element in the set
    • pollLastChar

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

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

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

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

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

      public CharRBTreeSet copy()
      Beschreibung aus Schnittstelle kopiert: CharCollection
      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 CharCollection
      Angegeben von:
      copy in Schnittstelle CharNavigableSet
      Angegeben von:
      copy in Schnittstelle CharSet
      Angegeben von:
      copy in Schnittstelle CharSortedSet
      Setzt außer Kraft:
      copy in Klasse AbstractCharSet
      Gibt zurück:
      a Shallow Copy of the collection
    • comparator

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

      public CharBidirectionalIterator iterator()
      Beschreibung aus Schnittstelle kopiert: CharCollection
      Returns a Type-Specific Iterator to reduce (un)boxing
      Angegeben von:
      iterator in Schnittstelle CharCollection
      Angegeben von:
      iterator in Schnittstelle CharIterable
      Angegeben von:
      iterator in Schnittstelle CharNavigableSet
      Angegeben von:
      iterator in Schnittstelle CharSet
      Angegeben von:
      iterator in Schnittstelle CharSortedSet
      Angegeben von:
      iterator in Schnittstelle Collection<Character>
      Angegeben von:
      iterator in Schnittstelle Iterable<Character>
      Angegeben von:
      iterator in Schnittstelle NavigableSet<Character>
      Angegeben von:
      iterator in Schnittstelle Set<Character>
      Angegeben von:
      iterator in Klasse AbstractCharSet
      Gibt zurück:
      a iterator of the collection
      Siehe auch:
    • iterator

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

      public CharBidirectionalIterator descendingIterator()
      Angegeben von:
      descendingIterator in Schnittstelle CharNavigableSet
      Angegeben von:
      descendingIterator in Schnittstelle NavigableSet<Character>
      Gibt zurück:
      a Type Specific desendingIterator
    • subSet

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