public class BooleanArraySet extends AbstractBooleanSet 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 boolean[] |
a
The backing array (valid up to
size, excluded). |
protected int |
size
The number of valid entries in
a. |
| Constructor and Description |
|---|
BooleanArraySet()
Creates a new empty array set.
|
BooleanArraySet(boolean[] a)
Creates a new array set using the given backing array.
|
BooleanArraySet(boolean[] a,
int size)
Creates a new array set using the given backing array and the given number of elements of the array.
|
BooleanArraySet(it.unimi.dsi.fastutil.booleans.BooleanCollection c)
Creates a new array set copying the contents of a given collection.
|
BooleanArraySet(BooleanSet c)
Creates a new array set copying the contents of a given collection.
|
BooleanArraySet(java.util.Collection<? extends java.lang.Boolean> c)
Creates a new array set copying the contents of a given set.
|
BooleanArraySet(int capacity)
Creates a new empty array set of given initial capacity.
|
BooleanArraySet(java.util.Set<? extends java.lang.Boolean> c)
Creates a new array set copying the contents of a given set.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(boolean k) |
void |
clear() |
BooleanArraySet |
clone()
Returns a deep copy of this set.
|
boolean |
contains(boolean k) |
boolean |
isEmpty() |
it.unimi.dsi.fastutil.booleans.BooleanIterator |
iterator()
Returns a type-specific iterator on the elements of this set.
|
static BooleanArraySet |
of()
Creates a new empty array set.
|
static BooleanArraySet |
of(boolean... a)
Creates a new array set using an array of elements.
|
static BooleanArraySet |
of(boolean e)
Creates a new array set using the element given.
|
static BooleanArraySet |
ofUnchecked()
Creates a new empty array set.
|
static BooleanArraySet |
ofUnchecked(boolean... a)
Creates a new array set using an array of elements.
|
boolean |
remove(boolean k)
Removes an element from this set.
|
int |
size() |
it.unimi.dsi.fastutil.booleans.BooleanSpliterator |
spliterator()
Returns a type-specific spliterator on the elements of this set.
|
boolean[] |
toArray(boolean[] a) |
boolean[] |
toBooleanArray() |
equals, hashCode, remadd, addAll, addAll, contains, containsAll, containsAll, remove, removeAll, removeAll, retainAll, retainAll, toBooleanArray, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitadd, contains, of, of, removeaddAll, containsAll, removeAll, removeIf, removeIf, retainAll, toBooleanArrayprotected transient boolean[] a
size, excluded).protected int size
a.public BooleanArraySet(boolean[] a)
It is the responsibility of the caller to ensure that the elements of a are distinct.
a - the backing array.public BooleanArraySet()
public BooleanArraySet(int capacity)
capacity - the initial capacity.public BooleanArraySet(it.unimi.dsi.fastutil.booleans.BooleanCollection c)
c - a collection.public BooleanArraySet(java.util.Collection<? extends java.lang.Boolean> c)
c - a collection.public BooleanArraySet(BooleanSet c)
c - a collection.public BooleanArraySet(java.util.Set<? extends java.lang.Boolean> c)
c - a collection.public BooleanArraySet(boolean[] 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 BooleanArraySet of()
of in interface BooleanSetpublic static BooleanArraySet of(boolean e)
of in interface BooleanSete - the element that the returned set will contain.e.public static BooleanArraySet of(boolean... 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.
of in interface BooleanSeta - the backing array of the returned array set.a.java.lang.IllegalArgumentException - if there were duplicate entries.public static BooleanArraySet ofUnchecked()
public static BooleanArraySet ofUnchecked(boolean... 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.booleans.BooleanIterator iterator()
BooleanSetiterator in interface it.unimi.dsi.fastutil.booleans.BooleanCollectioniterator in interface it.unimi.dsi.fastutil.booleans.BooleanIterableiterator in interface BooleanSetiterator in interface java.lang.Iterable<java.lang.Boolean>iterator in interface java.util.Collection<java.lang.Boolean>iterator in interface java.util.Set<java.lang.Boolean>iterator in class AbstractBooleanSetpublic it.unimi.dsi.fastutil.booleans.BooleanSpliterator 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.booleans.BooleanCollectionspliterator in interface it.unimi.dsi.fastutil.booleans.BooleanIterablespliterator in interface BooleanSetspliterator in interface java.lang.Iterable<java.lang.Boolean>spliterator in interface java.util.Collection<java.lang.Boolean>spliterator in interface java.util.Set<java.lang.Boolean>public boolean contains(boolean k)
contains in interface it.unimi.dsi.fastutil.booleans.BooleanCollectioncontains in class it.unimi.dsi.fastutil.booleans.AbstractBooleanCollectionpublic int size()
size in interface java.util.Collection<java.lang.Boolean>size in interface java.util.Set<java.lang.Boolean>size in class java.util.AbstractCollection<java.lang.Boolean>public boolean remove(boolean k)
AbstractBooleanSetrem() method
implemented by type-specific abstract Collection superclass.remove in interface BooleanSetremove in class AbstractBooleanSetCollection.remove(Object)public boolean add(boolean k)
add in interface it.unimi.dsi.fastutil.booleans.BooleanCollectionadd in class it.unimi.dsi.fastutil.booleans.AbstractBooleanCollectionpublic void clear()
clear in interface java.util.Collection<java.lang.Boolean>clear in interface java.util.Set<java.lang.Boolean>clear in class java.util.AbstractCollection<java.lang.Boolean>public boolean isEmpty()
isEmpty in interface java.util.Collection<java.lang.Boolean>isEmpty in interface java.util.Set<java.lang.Boolean>isEmpty in class java.util.AbstractCollection<java.lang.Boolean>public boolean[] toBooleanArray()
toBooleanArray in interface it.unimi.dsi.fastutil.booleans.BooleanCollectiontoBooleanArray in class it.unimi.dsi.fastutil.booleans.AbstractBooleanCollectionpublic boolean[] toArray(boolean[] a)
toArray in interface it.unimi.dsi.fastutil.booleans.BooleanCollectiontoArray in class it.unimi.dsi.fastutil.booleans.AbstractBooleanCollectionpublic BooleanArraySet 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