|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<K,Set<M>>
com.aliasi.util.ObjectToSet<K,M>
public class ObjectToSet<K,M>
An ObjectToSet provides a Map from
arbitrary objects to objects of class Set.
In addition to methods inherited from Map,
there are methods to add members to a set value and get
set values directly.
| Constructor Summary | |
|---|---|
ObjectToSet()
Construct a new object to set mapping. |
|
| Method Summary | |
|---|---|
void |
addMember(K key,
M member)
Add a member to the value of the set mapped to by the specified key. |
void |
addMembers(K key,
Set<? extends M> values)
Adds a set of members to the value of the set mapped to by the specified key. |
Set<M> |
getSet(K key)
Returns the set of values for the specified key, or the empty set if there have been none added. |
Iterator<M> |
memberIterator()
Returns an iterator over all values. |
Set<M> |
memberValues()
Returns a set constituting the union of all of the members of the set values for all of the keys. |
boolean |
removeMember(K key,
M member)
Removes the specified value from the set of values assigned to the specified key. |
| Methods inherited from class java.util.HashMap |
|---|
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public ObjectToSet()
| Method Detail |
|---|
public void addMember(K key,
M member)
key - Key whose set value will have the object.member - Object to add to the value of the key.
public boolean removeMember(K key,
M member)
key - Key whose members will have the value removed.member - Value to remove from the set of members assigned
to the key.
true if the value was in the set of
members for the key.
public void addMembers(K key,
Set<? extends M> values)
key - Key whose set value will have the object.values - Values to add to the set picked out by the key.public Set<M> memberValues()
public Set<M> getSet(K key)
HashMap.get(Object) method in that it returns the
empty set rather than null.
public Iterator<M> memberIterator()
memberValues()
will be returned at least once through this iteration.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||