public class IntArraySet extends AbstractIntSet 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 int[] |
a
The backing array (valid up to
size, excluded). |
protected int |
size
The number of valid entries in
a. |
| Constructor and Description |
|---|
IntArraySet()
Creates a new empty array set.
|
IntArraySet(java.util.Collection<? extends java.lang.Integer> c)
Creates a new array set copying the contents of a given set.
|
IntArraySet(int capacity)
Creates a new empty array set of given initial capacity.
|
IntArraySet(int[] a)
Creates a new array set using the given backing array.
|
IntArraySet(int[] a,
int size)
Creates a new array set using the given backing array and the given number of elements of the array.
|
IntArraySet(it.unimi.dsi.fastutil.ints.IntCollection c)
Creates a new array set copying the contents of a given collection.
|
IntArraySet(IntSet c)
Creates a new array set copying the contents of a given collection.
|
IntArraySet(java.util.Set<? extends java.lang.Integer> c)
Creates a new array set copying the contents of a given set.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(int k) |
void |
clear() |
IntArraySet |
clone()
Returns a deep copy of this set.
|
boolean |
contains(int k) |
boolean |
isEmpty() |
it.unimi.dsi.fastutil.ints.IntIterator |
iterator()
Returns a type-specific iterator on the elements of this set.
|
static IntArraySet |
of()
Creates a new empty array set.
|
static IntArraySet |
of(int... a)
Creates a new array set using an array of elements.
|
static IntArraySet |
of(int e)
Creates a new array set using the element given.
|
static IntArraySet |
ofUnchecked()
Creates a new empty array set.
|
static IntArraySet |
ofUnchecked(int... a)
Creates a new array set using an array of elements.
|
boolean |
remove(int k)
Removes an element from this set.
|
int |
size() |
it.unimi.dsi.fastutil.ints.IntSpliterator |
spliterator()
Returns a type-specific spliterator on the elements of this set.
|
int[] |
toArray(int[] a) |
int[] |
toIntArray() |
equals, hashCode, remadd, addAll, addAll, contains, containsAll, containsAll, forEach, remove, removeAll, removeAll, removeIf, retainAll, retainAll, toIntArray, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitprotected transient int[] a
size, excluded).protected int size
a.public IntArraySet(int[] a)
It is the responsibility of the caller to ensure that the elements of a are distinct.
a - the backing array.public IntArraySet()
public IntArraySet(int capacity)
capacity - the initial capacity.public IntArraySet(it.unimi.dsi.fastutil.ints.IntCollection c)
c - a collection.public IntArraySet(java.util.Collection<? extends java.lang.Integer> c)
c - a collection.public IntArraySet(IntSet c)
c - a collection.public IntArraySet(java.util.Set<? extends java.lang.Integer> c)
c - a collection.public IntArraySet(int[] 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 IntArraySet of()
public static IntArraySet of(int e)
public static IntArraySet of(int... 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 IntArraySet ofUnchecked()
public static IntArraySet ofUnchecked(int... 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.ints.IntIterator iterator()
IntSetiterator in interface it.unimi.dsi.fastutil.ints.IntCollectioniterator in interface it.unimi.dsi.fastutil.ints.IntIterableiterator in interface IntSetiterator in interface java.lang.Iterable<java.lang.Integer>iterator in interface java.util.Collection<java.lang.Integer>iterator in interface java.util.Set<java.lang.Integer>iterator in class AbstractIntSetpublic it.unimi.dsi.fastutil.ints.IntSpliterator 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.ints.IntCollectionspliterator in interface it.unimi.dsi.fastutil.ints.IntIterablespliterator in interface IntSetspliterator in interface java.lang.Iterable<java.lang.Integer>spliterator in interface java.util.Collection<java.lang.Integer>spliterator in interface java.util.Set<java.lang.Integer>public boolean contains(int k)
contains in interface it.unimi.dsi.fastutil.ints.IntCollectioncontains in class it.unimi.dsi.fastutil.ints.AbstractIntCollectionpublic int size()
size in interface java.util.Collection<java.lang.Integer>size in interface java.util.Set<java.lang.Integer>size in class java.util.AbstractCollection<java.lang.Integer>public boolean remove(int k)
AbstractIntSetrem() method
implemented by type-specific abstract Collection superclass.remove in interface IntSetremove in class AbstractIntSetCollection.remove(Object)public boolean add(int k)
add in interface it.unimi.dsi.fastutil.ints.IntCollectionadd in class it.unimi.dsi.fastutil.ints.AbstractIntCollectionpublic void clear()
clear in interface java.util.Collection<java.lang.Integer>clear in interface java.util.Set<java.lang.Integer>clear in class java.util.AbstractCollection<java.lang.Integer>public boolean isEmpty()
isEmpty in interface java.util.Collection<java.lang.Integer>isEmpty in interface java.util.Set<java.lang.Integer>isEmpty in class java.util.AbstractCollection<java.lang.Integer>public int[] toIntArray()
toIntArray in interface it.unimi.dsi.fastutil.ints.IntCollectiontoIntArray in class it.unimi.dsi.fastutil.ints.AbstractIntCollectionpublic int[] toArray(int[] a)
toArray in interface it.unimi.dsi.fastutil.ints.IntCollectiontoArray in class it.unimi.dsi.fastutil.ints.AbstractIntCollectionpublic IntArraySet 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