public class LiteSet<E> extends AbstractSet<E> implements Cloneable, Externalizable, ExternalizableLite
The LiteSet implementation switches at runtime between several different sub-implementations for storing the set of objects, described here:
instantiateSet().The LiteSet implementation supports the null value.
| Constructor and Description |
|---|
LiteSet()
Construct a LiteSet
|
LiteSet(Collection<? extends E> collection)
Construct a LiteSet containing the elements of the passed Collection.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E o)
Ensures that this Set contains the specified element.
|
boolean |
addAll(Collection<? extends E> collection)
Adds all of the elements in the specified Collection to this Set if they are not already present.
|
protected void |
checkShrinkFromOther()
After a mutation operation has reduced the size of an underlying Set, check if the delegation model should be replaced with a more size- efficient storage approach, and switch accordingly.
|
void |
clear()
Removes all of the elements from this Set.
|
Object |
clone()
Create a clone of this Set.
|
boolean |
contains(Object o)
Returns true if this Set contains the specified element.
|
boolean |
containsAll(Collection<?> collection)
Returns true if this Set contains all of the elements in the specified Collection.
|
Enumeration<E> |
elements()
Returns an Enumerator over the elements in this Set.
|
protected void |
initFromArray(Object[] ao, int c)
Initialize the contents of this Set from the passed array ao containing c values.
|
protected Set<E> |
instantiateSet()
(Factory pattern) Instantiate a Set object to store items in once the "lite" threshold has been exceeded.
|
boolean |
isEmpty()
Determine if this Set is empty.
|
Iterator<E> |
iterator()
Returns an Iterator over the elements in this Set.
|
void |
readExternal(DataInput in)
Restore the contents of this object by loading the object's state from the passed DataInput object.
|
void |
readExternal(ObjectInput in)
Initialize this object from the data in the passed ObjectInput stream.
|
boolean |
remove(Object o)
Removes the specified element from this Set if it is present.
|
boolean |
removeAll(Collection<?> collection)
Removes from this Set all of its elements that are contained in the specified Collection.
|
boolean |
retainAll(Collection<?> collection)
Retains only the elements in this Set that are contained in the specified Collection.
|
int |
size()
Returns the number of elements in this Set (its cardinality).
|
Object[] |
toArray()
Returns an array containing all of the elements in this Set.
|
Object[] |
toArray(Object[] aDest)
Returns an array (whose runtime type is that of the specified array) containing all of the elements in this Set.
|
void |
writeExternal(DataOutput out)
Save the contents of this object by storing the object's state into the passed DataOutput object.
|
void |
writeExternal(ObjectOutput out)
Write this object's data to the passed ObjectOutput stream.
|
equals, hashCodetoStringfinalize, getClass, notify, notifyAll, wait, wait, waitspliteratorparallelStream, removeIf, streampublic LiteSet()
public LiteSet(Collection<? extends E> collection)
collection - a Collectionpublic boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class AbstractCollection<E>public int size()
size in interface Collection<E>size in interface Set<E>size in class AbstractCollection<E>public boolean contains(Object o)
e such that (o==null ? e==null : o.equals(e)).contains in interface Collection<E>contains in interface Set<E>contains in class AbstractCollection<E>o - the object to check forpublic Iterator<E> iterator()
public Enumeration<E> elements()
public Object[] toArray()
toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>public Object[] toArray(Object[] aDest)
toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>aDest - the array into which the elements of this Set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purposeArrayStoreException - if the component type of aDest is not a supertype of the type of every element in this Setpublic boolean add(E o)
add in interface Collection<E>add in interface Set<E>add in class AbstractCollection<E>o - element to be added to this Setpublic boolean remove(Object o)
e such that (o==null ? e==null : o.equals(e)), if the Set contains such an element. Returns true if the Set contained the specified element (or equivalently, if the Set changed as a result of the call). The Set will not contain the specified element once the call returns.remove in interface Collection<E>remove in interface Set<E>remove in class AbstractCollection<E>o - object to be removed from this Set, if presentpublic boolean containsAll(Collection<?> collection)
containsAll in interface Collection<E>containsAll in interface Set<E>containsAll in class AbstractCollection<E>collection - Collection to be checked for containment in this Setpublic boolean addAll(Collection<? extends E> collection)
addAll in interface Collection<E>addAll in interface Set<E>addAll in class AbstractCollection<E>collection - Collection whose elements are to be added to this Setpublic boolean retainAll(Collection<?> collection)
retainAll in interface Collection<E>retainAll in interface Set<E>retainAll in class AbstractCollection<E>collection - collection that defines which elements this Set will retainpublic boolean removeAll(Collection<?> collection)
removeAll in interface Collection<E>removeAll in interface Set<E>removeAll in class AbstractSet<E>collection - Collection that defines which elements will be removed from this Setpublic void clear()
clear in interface Collection<E>clear in interface Set<E>clear in class AbstractCollection<E>public Object clone()
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface Externalizablein - the stream to read data from in order to restore the objectIOException - if an I/O exception occursClassNotFoundExceptionpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface Externalizableout - the stream to write the object toIOException - if an I/O exception occurspublic void readExternal(DataInput in) throws IOException
readExternal in interface ExternalizableLitein - the DataInput stream to read data from in order to restore the state of this objectIOException - if an I/O exception occursNotActiveException - if the object is not in its initial state, and therefore cannot be deserialized intopublic void writeExternal(DataOutput out) throws IOException
writeExternal in interface ExternalizableLiteout - the DataOutput stream to write the state of this object toIOException - if an I/O exception occursprotected Set<E> instantiateSet()
protected void initFromArray(Object[] ao, int c)
ao - the array that contains the values to place in this Setc - the number of values that will be placed into this Setprotected void checkShrinkFromOther()