public class ShortArraySet extends AbstractShortSet implements java.io.Serializable, java.lang.Cloneable
The main purpose of this implementation is that of wrapping cleanly the brute-force approach to the storage of a very small number of items: just put them into an array and scan linearly to find an item.
| Modifier and Type | Field and Description |
|---|---|
protected short[] |
a
The backing array (valid up to
size, excluded). |
protected int |
size
The number of valid entries in
a. |
| Constructor and Description |
|---|
ShortArraySet()
Creates a new empty array set.
|
ShortArraySet(java.util.Collection<? extends java.lang.Short> c)
Creates a new array set copying the contents of a given set.
|
ShortArraySet(int capacity)
Creates a new empty array set of given initial capacity.
|
ShortArraySet(java.util.Set<? extends java.lang.Short> c)
Creates a new array set copying the contents of a given set.
|
ShortArraySet(short[] a)
Creates a new array set using the given backing array.
|
ShortArraySet(short[] a,
int size)
Creates a new array set using the given backing array and the given number of elements of the array.
|
ShortArraySet(it.unimi.dsi.fastutil.shorts.ShortCollection c)
Creates a new array set copying the contents of a given collection.
|
ShortArraySet(ShortSet c)
Creates a new array set copying the contents of a given collection.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(short k) |
void |
clear() |
ShortArraySet |
clone()
Returns a deep copy of this set.
|
boolean |
contains(short k) |
boolean |
isEmpty() |
it.unimi.dsi.fastutil.shorts.ShortIterator |
iterator()
Returns a type-specific iterator on the elements of this set.
|
static ShortArraySet |
of()
Creates a new empty array set.
|
static ShortArraySet |
of(short... a)
Creates a new array set using an array of elements.
|
static ShortArraySet |
of(short e)
Creates a new array set using the element given.
|
static ShortArraySet |
ofUnchecked()
Creates a new empty array set.
|
static ShortArraySet |
ofUnchecked(short... a)
Creates a new array set using an array of elements.
|
boolean |
remove(short k)
Removes an element from this set.
|
int |
size() |
it.unimi.dsi.fastutil.shorts.ShortSpliterator |
spliterator()
Returns a type-specific spliterator on the elements of this set.
|
short[] |
toArray(short[] a) |
short[] |
toShortArray() |
equals, hashCode, remadd, addAll, addAll, contains, containsAll, containsAll, remove, removeAll, removeAll, retainAll, retainAll, toShortArray, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitadd, contains, of, of, removeaddAll, containsAll, intIterator, intParallelStream, intSpliterator, intStream, parallelStream, removeAll, removeIf, removeIf, removeIf, retainAll, stream, toShortArrayprotected transient short[] a
size, excluded).protected int size
a.public ShortArraySet(short[] a)
It is the responsibility of the caller to ensure that the elements of a are distinct.
a - the backing array.public ShortArraySet()
public ShortArraySet(int capacity)
capacity - the initial capacity.public ShortArraySet(it.unimi.dsi.fastutil.shorts.ShortCollection c)
c - a collection.public ShortArraySet(java.util.Collection<? extends java.lang.Short> c)
c - a collection.public ShortArraySet(ShortSet c)
c - a collection.public ShortArraySet(java.util.Set<? extends java.lang.Short> c)
c - a collection.public ShortArraySet(short[] a,
int size)
It is the responsibility of the caller to ensure that the first size elements of a are distinct.
a - the backing array.size - the number of valid elements in a.public static ShortArraySet of()
public static ShortArraySet of(short e)
public static ShortArraySet of(short... a)
Unlike the array accepting constructors, this method will throw if duplicate elements
are encountered. This adds a non-trivial validation burden. Use ofUnchecked() if you
know your input has no duplicates, which will skip this validation.
public static ShortArraySet ofUnchecked()
public static ShortArraySet ofUnchecked(short... a)
It is the responsibility of the caller to ensure that the elements of a are distinct.
a - the backing array of the returned array set.a.public it.unimi.dsi.fastutil.shorts.ShortIterator iterator()
ShortSetiterator in interface it.unimi.dsi.fastutil.shorts.ShortCollectioniterator in interface it.unimi.dsi.fastutil.shorts.ShortIterableiterator in interface ShortSetiterator in interface java.lang.Iterable<java.lang.Short>iterator in interface java.util.Collection<java.lang.Short>iterator in interface java.util.Set<java.lang.Short>iterator in class AbstractShortSetpublic it.unimi.dsi.fastutil.shorts.ShortSpliterator spliterator()
Set spliterators must report at least Spliterator.DISTINCT.
See Set.spliterator() for more documentation on the requirements
of the returned spliterator.
In addition to the usual trait of DISTINCT for
sets, the returned spliterator will also report
the trait ORDERED.
The returned spliterator is late-binding; it will track structural changes
after the current item, up until the first trySplit(),
at which point the maximum index will be fixed.
Structural changes before the current item or after the first
trySplit() will result in unspecified behavior.
spliterator in interface it.unimi.dsi.fastutil.shorts.ShortCollectionspliterator in interface it.unimi.dsi.fastutil.shorts.ShortIterablespliterator in interface ShortSetspliterator in interface java.lang.Iterable<java.lang.Short>spliterator in interface java.util.Collection<java.lang.Short>spliterator in interface java.util.Set<java.lang.Short>public boolean contains(short k)
contains in interface it.unimi.dsi.fastutil.shorts.ShortCollectioncontains in class it.unimi.dsi.fastutil.shorts.AbstractShortCollectionpublic int size()
size in interface java.util.Collection<java.lang.Short>size in interface java.util.Set<java.lang.Short>size in class java.util.AbstractCollection<java.lang.Short>public boolean remove(short k)
AbstractShortSetrem() method
implemented by type-specific abstract Collection superclass.remove in interface ShortSetremove in class AbstractShortSetCollection.remove(Object)public boolean add(short k)
add in interface it.unimi.dsi.fastutil.shorts.ShortCollectionadd in class it.unimi.dsi.fastutil.shorts.AbstractShortCollectionpublic void clear()
clear in interface java.util.Collection<java.lang.Short>clear in interface java.util.Set<java.lang.Short>clear in class java.util.AbstractCollection<java.lang.Short>public boolean isEmpty()
isEmpty in interface java.util.Collection<java.lang.Short>isEmpty in interface java.util.Set<java.lang.Short>isEmpty in class java.util.AbstractCollection<java.lang.Short>public short[] toShortArray()
toShortArray in interface it.unimi.dsi.fastutil.shorts.ShortCollectiontoShortArray in class it.unimi.dsi.fastutil.shorts.AbstractShortCollectionpublic short[] toArray(short[] a)
toArray in interface it.unimi.dsi.fastutil.shorts.ShortCollectiontoArray in class it.unimi.dsi.fastutil.shorts.AbstractShortCollectionpublic ShortArraySet clone()
This method performs a deep copy of this array set; the data stored in the set, however, is not cloned. Note that this makes a difference only for object keys.
clone in class java.lang.Object