Klasse ShortArraySet

Alle implementierten Schnittstellen:
Iterable<Short>, Collection<Short>, Set<Short>, ShortCollection, ShortIterable, ShortOrderedSet, ShortSet, ISizeProvider

public class ShortArraySet extends AbstractShortSet implements ShortOrderedSet
A Type Specific ArraySet implementation. That is based around the idea of List.indexOf(Object) for no duplication. Unless a array constructor is used the ArraySet does not allow for duplication. This implementation does not shrink the backing array
  • Konstruktordetails

    • ShortArraySet

      public ShortArraySet()
      Default Constructor
    • ShortArraySet

      public ShortArraySet(int capacity)
      Minimum Capacity Constructor
      Parameter:
      capacity - the minimum capacity of the internal array
      Löst aus:
      NegativeArraySizeException - if the capacity is negative
    • ShortArraySet

      public ShortArraySet(short[] array)
      Constructur using initial Array
      Parameter:
      array - the array that should be used for set.
    • ShortArraySet

      public ShortArraySet(short[] array, int length)
      Constructur using initial Array
      Parameter:
      array - the array that should be used for set.
      length - the amount of elements present within the array
      Löst aus:
      NegativeArraySizeException - if the length is negative
    • ShortArraySet

      @Deprecated public ShortArraySet(Collection<? extends Short> c)
      Veraltet.
      A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
      Parameter:
      c - the elements that should be added to the set.
      Note:
      this slowly checks every element to remove duplicates
    • ShortArraySet

      public ShortArraySet(ShortCollection c)
      A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
      Parameter:
      c - the elements that should be added to the set.
      Note:
      this slowly checks every element to remove duplicates
    • ShortArraySet

      @Deprecated public ShortArraySet(Set<? extends Short> s)
      Veraltet.
      A Helper constructor that fast copies the element out of a set into the ArraySet. Since it is assumed that there is no duplication in the first place
      Parameter:
      s - the set the element should be taken from
    • ShortArraySet

      public ShortArraySet(ShortSet s)
      A Helper constructor that fast copies the element out of a set into the ArraySet. Since it is assumed that there is no duplication in the first place
      Parameter:
      s - the set the element should be taken from
  • Methodendetails

    • 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
    • addAndMoveToFirst

      public boolean addAndMoveToFirst(short o)
      Beschreibung aus Schnittstelle kopiert: ShortOrderedSet
      A customized add method that allows you to insert into the first index.
      Angegeben von:
      addAndMoveToFirst in Schnittstelle ShortOrderedSet
      Parameter:
      o - the element that should be inserted
      Gibt zurück:
      true if it was added
      Siehe auch:
    • addAndMoveToLast

      public boolean addAndMoveToLast(short o)
      Beschreibung aus Schnittstelle kopiert: ShortOrderedSet
      A customized add method that allows you to insert into the last index.
      Angegeben von:
      addAndMoveToLast in Schnittstelle ShortOrderedSet
      Parameter:
      o - the element that should be inserted
      Gibt zurück:
      true if it was added
      Siehe auch:
    • moveToFirst

      public boolean moveToFirst(short o)
      Beschreibung aus Schnittstelle kopiert: ShortOrderedSet
      A specific move method to move a given key to the first index.
      Angegeben von:
      moveToFirst in Schnittstelle ShortOrderedSet
      Parameter:
      o - that should be moved to the first index
      Gibt zurück:
      true if the value was moved.
    • moveToLast

      public boolean moveToLast(short o)
      Beschreibung aus Schnittstelle kopiert: ShortOrderedSet
      A specific move method to move a given key to the last index.
      Angegeben von:
      moveToLast in Schnittstelle ShortOrderedSet
      Parameter:
      o - that should be moved to the first last
      Gibt zurück:
      true if the value was moved.
    • 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.
    • firstShort

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

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

      public boolean removeAll(ShortCollection c)
      Beschreibung aus Klasse kopiert: AbstractShortCollection
      A Type-Specific implementation of removeAll. This Implementation iterates over all elements and removes them as they were found in the other collection.
      Angegeben von:
      removeAll in Schnittstelle ShortCollection
      Setzt außer Kraft:
      removeAll in Klasse AbstractShortCollection
      Parameter:
      c - the elements that should be deleted
      Gibt zurück:
      true if the collection was modified.
      Siehe auch:
    • removeAll

      public boolean removeAll(ShortCollection c, ShortConsumer r)
      Beschreibung aus Schnittstelle kopiert: ShortCollection
      A Type-Specific removeAll function that reduces (un)boxing. It also notifies the remover of which exact element is going to be removed.
      Angegeben von:
      removeAll in Schnittstelle ShortCollection
      Setzt außer Kraft:
      removeAll in Klasse AbstractShortCollection
      Parameter:
      c - the collection of elements that should be removed
      r - elements that got removed
      Gibt zurück:
      true if any element was removed
      Siehe auch:
    • retainAll

      public boolean retainAll(ShortCollection c)
      Beschreibung aus Klasse kopiert: AbstractShortCollection
      A Type-Specific implementation of retainAll. This Implementation iterates over all elements and removes them as they were not found in the other collection.
      Angegeben von:
      retainAll in Schnittstelle ShortCollection
      Setzt außer Kraft:
      retainAll in Klasse AbstractShortCollection
      Parameter:
      c - the elements that should be kept
      Gibt zurück:
      true if the collection was modified.
      Siehe auch:
    • retainAll

      public boolean retainAll(ShortCollection c, ShortConsumer r)
      Beschreibung aus Schnittstelle kopiert: ShortCollection
      A Type-Specific retainAll function that reduces (un)boxing. It also notifies the remover of which exact element is going to be removed.
      Angegeben von:
      retainAll in Schnittstelle ShortCollection
      Setzt außer Kraft:
      retainAll in Klasse AbstractShortCollection
      Parameter:
      c - the collection of elements that should be kept
      r - elements that got removed
      Gibt zurück:
      true if any element was removed
      Siehe auch:
    • removeAll

      @Deprecated public boolean removeAll(Collection<?> c)
      Veraltet.
      Angegeben von:
      removeAll in Schnittstelle Collection<Short>
      Angegeben von:
      removeAll in Schnittstelle Set<Short>
      Setzt außer Kraft:
      removeAll in Klasse AbstractCollection<Short>
    • retainAll

      @Deprecated public boolean retainAll(Collection<?> c)
      Veraltet.
      Angegeben von:
      retainAll in Schnittstelle Collection<Short>
      Angegeben von:
      retainAll in Schnittstelle Set<Short>
      Setzt außer Kraft:
      retainAll in Klasse AbstractCollection<Short>
    • 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
    • pollFirstShort

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

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

      public boolean remIf(IntPredicate filter)
      Beschreibung aus Schnittstelle kopiert: ShortCollection
      A Type-Specific removeIf function to reduce (un)boxing.

      Removes elements that were selected by the filter

      Angegeben von:
      remIf in Schnittstelle ShortCollection
      Parameter:
      filter - Filters the elements that should be removed
      Gibt zurück:
      true if the collection was modified
      Siehe auch:
    • 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
    • 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 Set<Short>
      Angegeben von:
      iterator in Schnittstelle ShortCollection
      Angegeben von:
      iterator in Schnittstelle ShortIterable
      Angegeben von:
      iterator in Schnittstelle ShortOrderedSet
      Angegeben von:
      iterator in Schnittstelle ShortSet
      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: ShortOrderedSet
      A type Specific Iterator starting from a given key
      Angegeben von:
      iterator in Schnittstelle ShortOrderedSet
      Parameter:
      fromElement - the element the iterator should start from
      Gibt zurück:
      a iterator starting from the given element
    • copy

      public ShortArraySet 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 ShortOrderedSet
      Angegeben von:
      copy in Schnittstelle ShortSet
      Setzt außer Kraft:
      copy in Klasse AbstractShortSet
      Gibt zurück:
      a Shallow Copy of the 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>
    • 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
    • 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>