public class CharArraySet extends AbstractCharSet 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 char[] |
a
The backing array (valid up to
size, excluded). |
protected int |
size
The number of valid entries in
a. |
| Constructor and Description |
|---|
CharArraySet()
Creates a new empty array set.
|
CharArraySet(char[] a)
Creates a new array set using the given backing array.
|
CharArraySet(char[] a,
int size)
Creates a new array set using the given backing array and the given number of elements of the array.
|
CharArraySet(it.unimi.dsi.fastutil.chars.CharCollection c)
Creates a new array set copying the contents of a given collection.
|
CharArraySet(CharSet c)
Creates a new array set copying the contents of a given collection.
|
CharArraySet(java.util.Collection<? extends java.lang.Character> c)
Creates a new array set copying the contents of a given set.
|
CharArraySet(int capacity)
Creates a new empty array set of given initial capacity.
|
CharArraySet(java.util.Set<? extends java.lang.Character> c)
Creates a new array set copying the contents of a given set.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(char k) |
void |
clear() |
CharArraySet |
clone()
Returns a deep copy of this set.
|
boolean |
contains(char k) |
boolean |
isEmpty() |
it.unimi.dsi.fastutil.chars.CharIterator |
iterator()
Returns a type-specific iterator on the elements of this set.
|
static CharArraySet |
of()
Creates a new empty array set.
|
static CharArraySet |
of(char... a)
Creates a new array set using an array of elements.
|
static CharArraySet |
of(char e)
Creates a new array set using the element given.
|
static CharArraySet |
ofUnchecked()
Creates a new empty array set.
|
static CharArraySet |
ofUnchecked(char... a)
Creates a new array set using an array of elements.
|
boolean |
remove(char k)
Removes an element from this set.
|
int |
size() |
it.unimi.dsi.fastutil.chars.CharSpliterator |
spliterator()
Returns a type-specific spliterator on the elements of this set.
|
char[] |
toArray(char[] a) |
char[] |
toCharArray() |
equals, hashCode, remadd, addAll, addAll, contains, containsAll, containsAll, remove, removeAll, removeAll, retainAll, retainAll, toCharArray, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitprotected transient char[] a
size, excluded).protected int size
a.public CharArraySet(char[] a)
It is the responsibility of the caller to ensure that the elements of a are distinct.
a - the backing array.public CharArraySet()
public CharArraySet(int capacity)
capacity - the initial capacity.public CharArraySet(it.unimi.dsi.fastutil.chars.CharCollection c)
c - a collection.public CharArraySet(java.util.Collection<? extends java.lang.Character> c)
c - a collection.public CharArraySet(CharSet c)
c - a collection.public CharArraySet(java.util.Set<? extends java.lang.Character> c)
c - a collection.public CharArraySet(char[] 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 CharArraySet of()
public static CharArraySet of(char e)
public static CharArraySet of(char... 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 CharArraySet ofUnchecked()
public static CharArraySet ofUnchecked(char... 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.chars.CharIterator iterator()
CharSetiterator in interface it.unimi.dsi.fastutil.chars.CharCollectioniterator in interface it.unimi.dsi.fastutil.chars.CharIterableiterator in interface CharSetiterator in interface java.lang.Iterable<java.lang.Character>iterator in interface java.util.Collection<java.lang.Character>iterator in interface java.util.Set<java.lang.Character>iterator in class AbstractCharSetpublic it.unimi.dsi.fastutil.chars.CharSpliterator 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.chars.CharCollectionspliterator in interface it.unimi.dsi.fastutil.chars.CharIterablespliterator in interface CharSetspliterator in interface java.lang.Iterable<java.lang.Character>spliterator in interface java.util.Collection<java.lang.Character>spliterator in interface java.util.Set<java.lang.Character>public boolean contains(char k)
contains in interface it.unimi.dsi.fastutil.chars.CharCollectioncontains in class it.unimi.dsi.fastutil.chars.AbstractCharCollectionpublic int size()
size in interface java.util.Collection<java.lang.Character>size in interface java.util.Set<java.lang.Character>size in class java.util.AbstractCollection<java.lang.Character>public boolean remove(char k)
AbstractCharSetrem() method
implemented by type-specific abstract Collection superclass.remove in interface CharSetremove in class AbstractCharSetCollection.remove(Object)public boolean add(char k)
add in interface it.unimi.dsi.fastutil.chars.CharCollectionadd in class it.unimi.dsi.fastutil.chars.AbstractCharCollectionpublic void clear()
clear in interface java.util.Collection<java.lang.Character>clear in interface java.util.Set<java.lang.Character>clear in class java.util.AbstractCollection<java.lang.Character>public boolean isEmpty()
isEmpty in interface java.util.Collection<java.lang.Character>isEmpty in interface java.util.Set<java.lang.Character>isEmpty in class java.util.AbstractCollection<java.lang.Character>public char[] toCharArray()
toCharArray in interface it.unimi.dsi.fastutil.chars.CharCollectiontoCharArray in class it.unimi.dsi.fastutil.chars.AbstractCharCollectionpublic char[] toArray(char[] a)
toArray in interface it.unimi.dsi.fastutil.chars.CharCollectiontoArray in class it.unimi.dsi.fastutil.chars.AbstractCharCollectionpublic CharArraySet 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