ObjectCollection<K>, ObjectIterable<K>, ObjectSet<K>, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<K>, java.util.Collection<K>, java.util.Set<K>public class ObjectArraySet<K> extends AbstractObjectSet<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 |
|---|---|
ObjectArraySet() |
Creates a new empty array set.
|
ObjectArraySet(int capacity) |
Creates a new empty array set of given initial capacity.
|
ObjectArraySet(ObjectCollection<K> c) |
Creates a new array set copying the contents of a given collection.
|
ObjectArraySet(java.lang.Object[] a) |
Creates a new array set using the given backing array.
|
ObjectArraySet(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.
|
ObjectArraySet(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() |
|
ObjectArraySet<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 ObjectArraySet(java.lang.Object[] a)
It is responsibility of the caller that the elements of a are
distinct.
a - the backing array.public ObjectArraySet()
public ObjectArraySet(int capacity)
capacity - the initial capacity.public ObjectArraySet(ObjectCollection<K> c)
c - a collection.public ObjectArraySet(java.util.Collection<? extends K> c)
c - a collection.public ObjectArraySet(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()
ObjectCollection
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 ObjectCollection<K>iterator in interface ObjectIterable<K>iterator in interface ObjectSet<K>iterator in interface java.util.Set<K>iterator in class AbstractObjectSet<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 ObjectArraySet<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.