|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection
java.util.AbstractSet
com.tangosol.util.LiteSet
public class LiteSet
An implementation of java.util.Set that is optimal (in terms of both size and speed) for very small sets of data but still works excellently with large sets of data. This implementation is not thread-safe.
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 Summary | |
---|---|
LiteSet()
Construct a LiteSet |
|
LiteSet(Collection collection)
Construct a LiteSet containing the elements of the passed Collection. |
Method Summary | |
---|---|
boolean |
add(Object o)
Ensures that this Set contains the specified element. |
boolean |
addAll(Collection 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 |
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 |
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 |
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. |
Methods inherited from class java.util.AbstractSet |
---|
equals, hashCode |
Methods inherited from class java.util.AbstractCollection |
---|
toString |
Constructor Detail |
---|
public LiteSet()
public LiteSet(Collection collection)
collection
- a CollectionMethod Detail |
---|
public boolean isEmpty()
isEmpty
in interface Collection
isEmpty
in interface Set
isEmpty
in class AbstractCollection
public int size()
size
in interface Collection
size
in interface Set
size
in class AbstractCollection
public boolean contains(Object o)
e
such that
(o==null ? e==null : o.equals(e))
.
contains
in interface Collection
contains
in interface Set
contains
in class AbstractCollection
o
- the object to check for
public Iterator iterator()
iterator
in interface Iterable
iterator
in interface Collection
iterator
in interface Set
iterator
in class AbstractCollection
public Enumeration elements()
public Object[] toArray()
toArray
in interface Collection
toArray
in interface Set
toArray
in class AbstractCollection
public Object[] toArray(Object[] aDest)
toArray
in interface Collection
toArray
in interface Set
toArray
in class AbstractCollection
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 purpose
ArrayStoreException
- if the component type of aDest is
not a supertype of the type of every element in this Setpublic boolean add(Object o)
add
in interface Collection
add
in interface Set
add
in class AbstractCollection
o
- element to be added to this Set
public 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
remove
in interface Set
remove
in class AbstractCollection
o
- object to be removed from this Set, if present
public boolean containsAll(Collection collection)
containsAll
in interface Collection
containsAll
in interface Set
containsAll
in class AbstractCollection
collection
- Collection to be checked for containment in this
Set
public boolean addAll(Collection collection)
addAll
in interface Collection
addAll
in interface Set
addAll
in class AbstractCollection
collection
- Collection whose elements are to be added to this
Set
public boolean retainAll(Collection collection)
retainAll
in interface Collection
retainAll
in interface Set
retainAll
in class AbstractCollection
collection
- collection that defines which elements this Set will
retain
public boolean removeAll(Collection collection)
removeAll
in interface Collection
removeAll
in interface Set
removeAll
in class AbstractSet
collection
- Collection that defines which elements will be
removed from this Set
public void clear()
clear
in interface Collection
clear
in interface Set
clear
in class AbstractCollection
public Object clone()
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
in
- the stream to read data from in order to restore the object
IOException
- if an I/O exception occurs
ClassNotFoundException
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
out
- the stream to write the object to
IOException
- if an I/O exception occurspublic void readExternal(DataInput in) throws IOException
readExternal
in interface ExternalizableLite
in
- the DataInput stream to read data from in order to restore
the state of this object
IOException
- if an I/O exception occurs
NotActiveException
- if the object is not in its initial
state, and therefore cannot be deserialized intopublic void writeExternal(DataOutput out) throws IOException
writeExternal
in interface ExternalizableLite
out
- the DataOutput stream to write the state of this object to
IOException
- if an I/O exception occursprotected Set 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()
|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |