com.myjavatools.lib.foundation
Interface Map2<X,Y,V>

All Known Implementing Classes:
AbstractMap2, IndexedHashMap2, IndexedMap2, IndexedTreeMap2

public interface Map2<X,Y,V>

Map2 is an interface that represents a two-parameter map.

Copyright: This is public domain; The right of people to use, distribute, copy or improve the contents of the following may not be restricted.

Company: My Java Tools

Version:
6.0 12/10/2006

Nested Class Summary
static interface Map2.Entry<X,Y,V>
          A map entry (key1-key2-value pair).
 
Method Summary
 void clear()
          Removes all mappings from this map.
 boolean containsKeyPair(java.lang.Object key1, java.lang.Object key2)
          Returns true if this map contains a mapping for the specified key pair.
 java.util.Map<Y,V> curry1(X key1)
          Currying by first argument.
 java.util.Map<X,V> curry2(Y key2)
          Currying by second argument.
 java.util.Set<Map2.Entry<X,Y,V>> entrySet()
          Returns a set view of the mappings contained in this map.
 V get(X key1, Y key2)
          Returns the value to which this map maps the specified key pair, and null if the map contains no mapping for these keys.
 boolean isEmpty()
           
 java.util.Set<X> keySet1()
          A Map2 has two sets of keys, first component and second component.
 java.util.Set<Y> keySet2()
          A Map2 has two sets of keys, first component and second component.
 V put(X key1, Y key2, V value)
          Associates the specified value with the specified key pair.
 void putAll(Map2<? extends X,? extends Y,? extends V> t)
          Copies all of the mappings from the specified map to this map.
 V remove(X key1, Y key2)
          Removes the mapping for this key pair from this map if it is present.
 int size()
           
 java.util.Collection<V> values()
          Returns a collection view of the values contained in this map.
 

Method Detail

size

int size()
Returns:
the number of key-value mappings in this map.

isEmpty

boolean isEmpty()
Returns:
true if this map contains no key-value mappings.

containsKeyPair

boolean containsKeyPair(java.lang.Object key1,
                        java.lang.Object key2)
Returns true if this map contains a mapping for the specified key pair.

Parameters:
key1 - first key.
key2 - second key.
Returns:
true if this map contains a mapping for this key pair.

get

V get(X key1,
      Y key2)
Returns the value to which this map maps the specified key pair, and null if the map contains no mapping for these keys.

Parameters:
key1 - first key.
key2 - second key.
Returns:
the value to which this map maps the specified keys, or null if the map contains no mapping for these keys.
Throws:
java.lang.ClassCastException - if the key is of an inappropriate type for this map (optional).
java.lang.NullPointerException - if the key is null and this map does not permit null keys (optional).
See Also:
#containsKey(Object)

put

V put(X key1,
      Y key2,
      V value)
Associates the specified value with the specified key pair. If the map previously contained a mapping for this key pair, the old value is replaced by the specified value.

Parameters:
key1 - first key.
key2 - second key.
value - value to be associated with the specified key pair.
Returns:
previous value associated with specified key, or null if there was no mapping for key.

remove

V remove(X key1,
         Y key2)
Removes the mapping for this key pair from this map if it is present.

Returns the value to which the map previously associated the keys, or null if the map contained no mapping for this key pair.

Parameters:
key1 - first key.
key2 - second key.
Returns:
previous value, or null if there was no mapping for key.

putAll

void putAll(Map2<? extends X,? extends Y,? extends V> t)
Copies all of the mappings from the specified map to this map.

Parameters:
source - Mappings to be stored in this map.

clear

void clear()
Removes all mappings from this map.


keySet1

java.util.Set<X> keySet1()
A Map2 has two sets of keys, first component and second component. This method returns an unmodifiable set view of the set of keys of the first component. The set is backed by the map, so changes to the map are reflected in the set. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined.

Returns:
an unmodifiable set view of the keys contained in this map.

keySet2

java.util.Set<Y> keySet2()
A Map2 has two sets of keys, first component and second component. This method returns an unmodifiable set view of the set of keys of the second component. The set is backed by the map, so changes to the map are reflected in the set. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined.

Returns:
an unmodifiable set view of the keys contained in this map.

values

java.util.Collection<V> values()
Returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection. If the map is modified while an iteration over the collection is in progress, the results of the iteration are undefined.

Returns:
a collection view of the values contained in this map.

curry1

java.util.Map<Y,V> curry1(X key1)
Currying by first argument. Produces a map that for each Y key2 returns the same value as get(key1, key2) would return. If key1 is not present in the set of keys, an empty map is returned.

Parameters:
key1 - X
Returns:
Map resulting map.

curry2

java.util.Map<X,V> curry2(Y key2)
Currying by second argument. Produces a map that for each X key1 returns the same value as get(key1, key2) would return. If key2 is not present in the set of keys, an empty map is returned.

Parameters:
key2 - X
Returns:
Map resulting map.

entrySet

java.util.Set<Map2.Entry<X,Y,V>> entrySet()
Returns a set view of the mappings contained in this map. Each element in the returned set is a Map2.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa.

Returns:
a set view of the mappings contained in this map.