public class FloatArraySet extends AbstractFloatSet 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 float[] |
a
The backing array (valid up to
size, excluded). |
protected int |
size
The number of valid entries in
a. |
| Constructor and Description |
|---|
FloatArraySet()
Creates a new empty array set.
|
FloatArraySet(java.util.Collection<? extends java.lang.Float> c)
Creates a new array set copying the contents of a given set.
|
FloatArraySet(float[] a)
Creates a new array set using the given backing array.
|
FloatArraySet(float[] a,
int size)
Creates a new array set using the given backing array and the given number of elements of the array.
|
FloatArraySet(it.unimi.dsi.fastutil.floats.FloatCollection c)
Creates a new array set copying the contents of a given collection.
|
FloatArraySet(FloatSet c)
Creates a new array set copying the contents of a given collection.
|
FloatArraySet(int capacity)
Creates a new empty array set of given initial capacity.
|
FloatArraySet(java.util.Set<? extends java.lang.Float> c)
Creates a new array set copying the contents of a given set.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(float k) |
void |
clear() |
FloatArraySet |
clone()
Returns a deep copy of this set.
|
boolean |
contains(float k) |
boolean |
isEmpty() |
it.unimi.dsi.fastutil.floats.FloatIterator |
iterator()
Returns a type-specific iterator on the elements of this set.
|
static FloatArraySet |
of()
Creates a new empty array set.
|
static FloatArraySet |
of(float... a)
Creates a new array set using an array of elements.
|
static FloatArraySet |
of(float e)
Creates a new array set using the element given.
|
static FloatArraySet |
ofUnchecked()
Creates a new empty array set.
|
static FloatArraySet |
ofUnchecked(float... a)
Creates a new array set using an array of elements.
|
boolean |
remove(float k)
Removes an element from this set.
|
int |
size() |
it.unimi.dsi.fastutil.floats.FloatSpliterator |
spliterator()
Returns a type-specific spliterator on the elements of this set.
|
float[] |
toArray(float[] a) |
float[] |
toFloatArray() |
equals, hashCode, remadd, addAll, addAll, contains, containsAll, containsAll, remove, removeAll, removeAll, retainAll, retainAll, toFloatArray, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitadd, contains, of, of, removeaddAll, containsAll, doubleIterator, doubleParallelStream, doubleSpliterator, doubleStream, parallelStream, removeAll, removeIf, removeIf, removeIf, retainAll, stream, toFloatArrayprotected transient float[] a
size, excluded).protected int size
a.public FloatArraySet(float[] a)
It is the responsibility of the caller to ensure that the elements of a are distinct.
a - the backing array.public FloatArraySet()
public FloatArraySet(int capacity)
capacity - the initial capacity.public FloatArraySet(it.unimi.dsi.fastutil.floats.FloatCollection c)
c - a collection.public FloatArraySet(java.util.Collection<? extends java.lang.Float> c)
c - a collection.public FloatArraySet(FloatSet c)
c - a collection.public FloatArraySet(java.util.Set<? extends java.lang.Float> c)
c - a collection.public FloatArraySet(float[] 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 FloatArraySet of()
public static FloatArraySet of(float e)
public static FloatArraySet of(float... 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 FloatArraySet ofUnchecked()
public static FloatArraySet ofUnchecked(float... 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.floats.FloatIterator iterator()
FloatSetiterator in interface it.unimi.dsi.fastutil.floats.FloatCollectioniterator in interface it.unimi.dsi.fastutil.floats.FloatIterableiterator in interface FloatSetiterator in interface java.lang.Iterable<java.lang.Float>iterator in interface java.util.Collection<java.lang.Float>iterator in interface java.util.Set<java.lang.Float>iterator in class AbstractFloatSetpublic it.unimi.dsi.fastutil.floats.FloatSpliterator 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.floats.FloatCollectionspliterator in interface it.unimi.dsi.fastutil.floats.FloatIterablespliterator in interface FloatSetspliterator in interface java.lang.Iterable<java.lang.Float>spliterator in interface java.util.Collection<java.lang.Float>spliterator in interface java.util.Set<java.lang.Float>public boolean contains(float k)
contains in interface it.unimi.dsi.fastutil.floats.FloatCollectioncontains in class it.unimi.dsi.fastutil.floats.AbstractFloatCollectionpublic int size()
size in interface java.util.Collection<java.lang.Float>size in interface java.util.Set<java.lang.Float>size in class java.util.AbstractCollection<java.lang.Float>public boolean remove(float k)
AbstractFloatSetrem() method
implemented by type-specific abstract Collection superclass.remove in interface FloatSetremove in class AbstractFloatSetCollection.remove(Object)public boolean add(float k)
add in interface it.unimi.dsi.fastutil.floats.FloatCollectionadd in class it.unimi.dsi.fastutil.floats.AbstractFloatCollectionpublic void clear()
clear in interface java.util.Collection<java.lang.Float>clear in interface java.util.Set<java.lang.Float>clear in class java.util.AbstractCollection<java.lang.Float>public boolean isEmpty()
isEmpty in interface java.util.Collection<java.lang.Float>isEmpty in interface java.util.Set<java.lang.Float>isEmpty in class java.util.AbstractCollection<java.lang.Float>public float[] toFloatArray()
toFloatArray in interface it.unimi.dsi.fastutil.floats.FloatCollectiontoFloatArray in class it.unimi.dsi.fastutil.floats.AbstractFloatCollectionpublic float[] toArray(float[] a)
toArray in interface it.unimi.dsi.fastutil.floats.FloatCollectiontoArray in class it.unimi.dsi.fastutil.floats.AbstractFloatCollectionpublic FloatArraySet 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