All Packages Class Hierarchy This Package Previous Next Index
Interface collections.Map
- public interface interface Map
- extends Collection
Maps maintain keyed elements. Any kind of Object
may serve as a key for an element.
-
aKeyOf(Object)
- Return a key associated with element.
-
at(Object)
- Return the element associated with Key key.
-
canIncludeKey(Object)
- Report whether the Map COULD include k as a key
Always returns false if k is null
-
includesAt(Object, Object)
- Report whether there exists a (key, value) pair
-
includesKey(Object)
- Report whether there exists any element with Key key.
-
keys()
- Return an enumeration that may be used to traverse through
the keys (not elements) of the collection.
-
puttingAt(Object, Object)
- Construct a new Map that is a clone of self except
that it includes the new pair.
-
removingAt(Object)
- Construct a new Map that is a clone of self except
that it does not include the given key.
canIncludeKey
public abstract boolean canIncludeKey(Object k)
- Report whether the Map COULD include k as a key
Always returns false if k is null
includesKey
public abstract boolean includesKey(Object key)
- Report whether there exists any element with Key key.
- Returns:
- true if there is such an element
includesAt
public abstract boolean includesAt(Object key,
Object value)
- Report whether there exists a (key, value) pair
- Returns:
- true if there is such an element
keys
public abstract CollectionEnumeration keys()
- Return an enumeration that may be used to traverse through
the keys (not elements) of the collection. The corresponding
elements can be looked at by using at(k) for each key k. For example:
Enumeration keys = amap.keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object value = amap.at(key)
// ...
}
- Returns:
- the enumeration
at
public abstract Object at(Object key) throws NoSuchElementException
- Return the element associated with Key key.
- Parameters:
- key - a key
- Returns:
- element such that includesAt(key, element)
- Throws: NoSuchElementException
- if !includesKey(key)
aKeyOf
public abstract Object aKeyOf(Object element)
- Return a key associated with element. There may be any
number of keys associated with any element, but this returns only
one of them (any arbitrary one), or null if no such key exists.
- Parameters:
- element, - a value to try to find a key for.
- Returns:
- k, such that
(k == null && !includes(element)) || includesAt(k, element)
puttingAt
public abstract Map puttingAt(Object key,
Object element) throws IllegalElementException
- Construct a new Map that is a clone of self except
that it includes the new pair. If there already exists
another pair with the same key, the new collection will
instead have one with the new elment.
- Parameters:
- the - key for element to add
- the - element to add
- Returns:
- the new Map c, for which:
c.at(key).equals(element) &&
foreach (k in keys()) c.at(v).equals(at(k))
foreach (k in c.keys()) (!k.equals(key)) --> c.at(v).equals(at(k))
removingAt
public abstract Map removingAt(Object key)
- Construct a new Map that is a clone of self except
that it does not include the given key.
It is NOT an error to exclude a non-existent key.
- Parameters:
- key - the key for the par to remove
- element - the element for the par to remove
- Returns:
- the new Map c, for which:
foreach (v in c.keys()) includesAt(v, at(v)) &&
!c.includesKey(key)
All Packages Class Hierarchy This Package Previous Next Index