public class LongArraySet extends AbstractLongSet 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 long[] |
a
The backing array (valid up to
size, excluded). |
protected int |
size
The number of valid entries in
a. |
| Constructor and Description |
|---|
LongArraySet()
Creates a new empty array set.
|
LongArraySet(java.util.Collection<? extends java.lang.Long> c)
Creates a new array set copying the contents of a given set.
|
LongArraySet(int capacity)
Creates a new empty array set of given initial capacity.
|
LongArraySet(long[] a)
Creates a new array set using the given backing array.
|
LongArraySet(long[] a,
int size)
Creates a new array set using the given backing array and the given number of elements of the array.
|
LongArraySet(it.unimi.dsi.fastutil.longs.LongCollection c)
Creates a new array set copying the contents of a given collection.
|
LongArraySet(LongSet c)
Creates a new array set copying the contents of a given collection.
|
LongArraySet(java.util.Set<? extends java.lang.Long> c)
Creates a new array set copying the contents of a given set.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(long k) |
void |
clear() |
LongArraySet |
clone()
Returns a deep copy of this set.
|
boolean |
contains(long k) |
boolean |
isEmpty() |
it.unimi.dsi.fastutil.longs.LongIterator |
iterator()
Returns a type-specific iterator on the elements of this set.
|
static LongArraySet |
of()
Creates a new empty array set.
|
static LongArraySet |
of(long... a)
Creates a new array set using an array of elements.
|
static LongArraySet |
of(long e)
Creates a new array set using the element given.
|
static LongArraySet |
ofUnchecked()
Creates a new empty array set.
|
static LongArraySet |
ofUnchecked(long... a)
Creates a new array set using an array of elements.
|
boolean |
remove(long k)
Removes an element from this set.
|
int |
size() |
it.unimi.dsi.fastutil.longs.LongSpliterator |
spliterator()
Returns a type-specific spliterator on the elements of this set.
|
long[] |
toArray(long[] a) |
long[] |
toLongArray() |
equals, hashCode, remadd, addAll, addAll, contains, containsAll, containsAll, forEach, remove, removeAll, removeAll, removeIf, retainAll, retainAll, toLongArray, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitprotected transient long[] a
size, excluded).protected int size
a.public LongArraySet(long[] a)
It is the responsibility of the caller to ensure that the elements of a are distinct.
a - the backing array.public LongArraySet()
public LongArraySet(int capacity)
capacity - the initial capacity.public LongArraySet(it.unimi.dsi.fastutil.longs.LongCollection c)
c - a collection.public LongArraySet(java.util.Collection<? extends java.lang.Long> c)
c - a collection.public LongArraySet(LongSet c)
c - a collection.public LongArraySet(java.util.Set<? extends java.lang.Long> c)
c - a collection.public LongArraySet(long[] 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 LongArraySet of()
public static LongArraySet of(long e)
public static LongArraySet of(long... 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 LongArraySet ofUnchecked()
public static LongArraySet ofUnchecked(long... 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.longs.LongIterator iterator()
LongSetiterator in interface it.unimi.dsi.fastutil.longs.LongCollectioniterator in interface it.unimi.dsi.fastutil.longs.LongIterableiterator in interface LongSetiterator in interface java.lang.Iterable<java.lang.Long>iterator in interface java.util.Collection<java.lang.Long>iterator in interface java.util.Set<java.lang.Long>iterator in class AbstractLongSetpublic it.unimi.dsi.fastutil.longs.LongSpliterator 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.longs.LongCollectionspliterator in interface it.unimi.dsi.fastutil.longs.LongIterablespliterator in interface LongSetspliterator in interface java.lang.Iterable<java.lang.Long>spliterator in interface java.util.Collection<java.lang.Long>spliterator in interface java.util.Set<java.lang.Long>public boolean contains(long k)
contains in interface it.unimi.dsi.fastutil.longs.LongCollectioncontains in class it.unimi.dsi.fastutil.longs.AbstractLongCollectionpublic int size()
size in interface java.util.Collection<java.lang.Long>size in interface java.util.Set<java.lang.Long>size in class java.util.AbstractCollection<java.lang.Long>public boolean remove(long k)
AbstractLongSetrem() method
implemented by type-specific abstract Collection superclass.remove in interface LongSetremove in class AbstractLongSetCollection.remove(Object)public boolean add(long k)
add in interface it.unimi.dsi.fastutil.longs.LongCollectionadd in class it.unimi.dsi.fastutil.longs.AbstractLongCollectionpublic void clear()
clear in interface java.util.Collection<java.lang.Long>clear in interface java.util.Set<java.lang.Long>clear in class java.util.AbstractCollection<java.lang.Long>public boolean isEmpty()
isEmpty in interface java.util.Collection<java.lang.Long>isEmpty in interface java.util.Set<java.lang.Long>isEmpty in class java.util.AbstractCollection<java.lang.Long>public long[] toLongArray()
toLongArray in interface it.unimi.dsi.fastutil.longs.LongCollectiontoLongArray in class it.unimi.dsi.fastutil.longs.AbstractLongCollectionpublic long[] toArray(long[] a)
toArray in interface it.unimi.dsi.fastutil.longs.LongCollectiontoArray in class it.unimi.dsi.fastutil.longs.AbstractLongCollectionpublic LongArraySet 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