ObjectIterable<K>, ReferenceCollection<K>, ReferenceSet<K>, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<K>, java.util.Collection<K>, java.util.Set<K>public class ReferenceArraySet<K> extends AbstractReferenceSet<K> 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.
| Constructor | Description |
|---|---|
ReferenceArraySet() |
Creates a new empty array set.
|
ReferenceArraySet(int capacity) |
Creates a new empty array set of given initial capacity.
|
ReferenceArraySet(ReferenceCollection<K> c) |
Creates a new array set copying the contents of a given collection.
|
ReferenceArraySet(java.lang.Object[] a) |
Creates a new array set using the given backing array.
|
ReferenceArraySet(java.lang.Object[] a,
int size) |
Creates a new array set using the given backing array and the given number of
elements of the array.
|
ReferenceArraySet(java.util.Collection<? extends K> c) |
Creates a new array set copying the contents of a given set.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
add(K k) |
|
void |
clear() |
|
ReferenceArraySet<K> |
clone() |
Returns a deep copy of this set.
|
boolean |
contains(java.lang.Object k) |
|
boolean |
isEmpty() |
|
ObjectIterator<K> |
iterator() |
Returns a type-specific iterator on the elements of this collection.
|
boolean |
remove(java.lang.Object k) |
|
int |
size() |
addAll, containsAll, removeAll, retainAll, toArray, toArraytoStringequals, hashCodepublic ReferenceArraySet(java.lang.Object[] a)
It is responsibility of the caller that the elements of a are
distinct.
a - the backing array.public ReferenceArraySet()
public ReferenceArraySet(int capacity)
capacity - the initial capacity.public ReferenceArraySet(ReferenceCollection<K> c)
c - a collection.public ReferenceArraySet(java.util.Collection<? extends K> c)
c - a collection.public ReferenceArraySet(java.lang.Object[] a,
int size)
It is responsibility of the caller that the first size elements of
a are distinct.
a - the backing array.size - the number of valid elements in a.public ObjectIterator<K> iterator()
ReferenceCollection
Note that this specification strengthens the one given in
Iterable.iterator(), which was already strengthened in the
corresponding type-specific class, but was weakened by the fact that this
interface extends Collection.
iterator in interface java.util.Collection<K>iterator in interface java.lang.Iterable<K>iterator in interface ObjectIterable<K>iterator in interface ReferenceCollection<K>iterator in interface ReferenceSet<K>iterator in interface java.util.Set<K>iterator in class AbstractReferenceSet<K>Iterable.iterator()public boolean contains(java.lang.Object k)
public int size()
public boolean remove(java.lang.Object k)
public boolean add(K k)
public void clear()
public boolean isEmpty()
public ReferenceArraySet<K> 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.