public class MapSet extends AbstractSet implements Cloneable, Externalizable, ExternalizableLite
| Modifier and Type | Field and Description |
|---|---|
protected Map |
m_map
The underlying Map.
|
protected static Object |
NO_VALUE
A no-value object.
|
| Constructor and Description |
|---|
MapSet()
Default constructor.
|
MapSet(Map map)
Construct a MapSet that uses the given Map for its underlying storage.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Object o)
Ensures that this Set contains the specified element.
|
boolean |
addAll(Collection coll)
Adds all of the elements in the specified Collection to this Set if they're not already present.
|
void |
clear()
Removes all of the elements from this Set.
|
Object |
clone()
Create a clone of this MapSet.
|
boolean |
contains(Object o)
Returns true if this Set contains the specified element.
|
boolean |
containsAll(Collection coll)
Returns true if this Set contains all of the elements in the specified Collection.
|
Map |
getMap()
Obtain the underlying Map for purposes of synchronization or read-only access; the caller must never directly modify the returned Map.
|
protected Map |
instantiateMap()
Factory pattern: Provide an underlying Map for this Set implementation to store its contents in.
|
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 contents of the passed object stream.
|
boolean |
remove(Object o)
Removes the specified element from this Set if it is present.
|
boolean |
removeAll(Collection coll)
Removes from this Set all of its elements that are contained in the specified Collection.
|
boolean |
retainAll(Collection coll)
Retains only the elements in this Set that are contained in the specified Collection.
|
int |
size()
Returns the number of elements in this Set.
|
Object[] |
toArray()
Returns an array containing all of the elements in this Set.
|
Object[] |
toArray(Object[] ao)
Returns an array containing all of the elements in this set whose runtime type is that of the specified array.
|
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 the contents of this object into the passed object stream.
|
equals, hashCodeisEmpty, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitisEmpty, spliteratorparallelStream, removeIf, streamprotected static final Object NO_VALUE
protected transient Map m_map
public MapSet()
MapSet(Map) constructor. To change the default Map implementation, sub-class the MapSet and override the instantiateMap() method.public MapSet(Map map)
map - the underlying Map objectpublic int size()
size in interface Collectionsize in interface Setsize in class AbstractCollectionpublic boolean contains(Object o)
contains in interface Collectioncontains in interface Setcontains in class AbstractCollectionpublic Iterator iterator()
iterator in interface Iterableiterator in interface Collectioniterator in interface Setiterator in class AbstractCollectionpublic Object[] toArray()
Collection.toArray() method.toArray in interface CollectiontoArray in interface SettoArray in class AbstractCollectionpublic Object[] toArray(Object[] ao)
Collection.toArray(Object[]) method.toArray in interface CollectiontoArray in interface SettoArray in class AbstractCollectionao - 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 - the runtime type of a is not a supertype of the runtime type of every element in this Setpublic boolean add(Object o)
add in interface Collectionadd in interface Setadd in class AbstractCollectiono - element to be added to this Setpublic boolean remove(Object o)
remove in interface Collectionremove in interface Setremove in class AbstractCollectiono - object to be removed from this Set, if presentpublic boolean containsAll(Collection coll)
containsAll in interface CollectioncontainsAll in interface SetcontainsAll in class AbstractCollectioncoll - Collection to be checked for containment in this Setcontains(Object)public boolean addAll(Collection coll)
addAll in interface CollectionaddAll in interface SetaddAll in class AbstractCollectioncoll - Collection whose elements are to be added to this Setadd(Object)public boolean retainAll(Collection coll)
retainAll in interface CollectionretainAll in interface SetretainAll in class AbstractCollectioncoll - Collection that defines which elements this Set will retainpublic boolean removeAll(Collection coll)
removeAll in interface CollectionremoveAll in interface SetremoveAll in class AbstractSetcoll - Collection that defines which elements will be removed from this Setremove(Object)public void clear()
clear in interface Collectionclear in interface Setclear in class AbstractCollectionpublic Map getMap()
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 Map instantiateMap()