|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.myjavatools.lib.foundation.AbstractMap2<X,Y,V>
com.myjavatools.lib.foundation.IndexedMap2<X,Y,V>
public abstract class IndexedMap2<X,Y,V>
IndexedMap2 is an abstract class that implements a two-parameter map with indexes for both parameters.
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
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.myjavatools.lib.foundation.AbstractMap2 |
---|
AbstractMap2.Entry<X,Y,V> |
Constructor Summary | |
---|---|
IndexedMap2()
Default constructor. |
Method Summary | |
---|---|
boolean |
containsKeyPair(java.lang.Object key1,
java.lang.Object key2)
Returns true if this map contains a mapping for the
specified key pair.
This implementation iterates over entrySet() searching for an
entry with the specified keys.
This implementation uses index to check for key pair presence. |
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. This implementation builds the map on every call. This implementation uses the index to return a Map<Y,V>
view of Map<Y,Entry<X,Y,Z>> map that is stored in index. |
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. This implementation builds the map on every call. This implementation uses the index to return a Map<X,V>
view of Map<Y,Entry<X,Y,Z>> map that is stored in index. |
protected java.util.Map<Y,AbstractMap2.Entry<X,Y,V>> |
ensureSlot1(X key1)
|
protected java.util.Map<X,AbstractMap2.Entry<X,Y,V>> |
ensureSlot2(Y key2)
|
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.
This implementation iterates over entrySet() searching for an
entry with the specified pair of keys.
This implementation uses two indexes. |
protected AbstractMap2.Entry<X,Y,V> |
getEntry(java.lang.Object key1,
java.lang.Object key2)
|
java.util.Set<X> |
keySet1()
A Map2 has two sets of keys, first component and second component. This implementation returns a Set that subclasses AbstractSet and is based on the map's entrySet. |
java.util.Set<Y> |
keySet2()
A Map2 has two sets of keys, first component and second component. This implementation returns a Set that subclasses AbstractSet and is based on the map's entrySet. |
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. This implementation always throws an UnsupportedOperationException .
This implementation uses and updates two indexes. |
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.
This implementation iterates over |
Methods inherited from class com.myjavatools.lib.foundation.AbstractMap2 |
---|
clear, containsValue, entrySet, equal, equals, hashCode, isEmpty, putAll, size, toString, values |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public IndexedMap2()
Method Detail |
---|
protected AbstractMap2.Entry<X,Y,V> getEntry(java.lang.Object key1, java.lang.Object key2)
protected java.util.Map<Y,AbstractMap2.Entry<X,Y,V>> ensureSlot1(X key1)
protected java.util.Map<X,AbstractMap2.Entry<X,Y,V>> ensureSlot2(Y key2)
public V get(X key1, Y key2)
null
if the map contains no mapping for these keys.
This implementation iterates over entrySet()
searching for an
entry with the specified pair of keys. If such an entry is found,
the entry's value is returned. If the iteration terminates without
finding such an entry, null
is returned. Note that
this implementation requires linear time in the size of the map;
many implementations will override this method.
This implementation uses two indexes.
get
in interface Map2<X,Y,V>
get
in class AbstractMap2<X,Y,V>
key1
- first keykey2
- second key
#containsKeyPair(X,Y)
public V put(X key1, Y key2, V value)
UnsupportedOperationException
.
This implementation uses and updates two indexes.
put
in interface Map2<X,Y,V>
put
in class AbstractMap2<X,Y,V>
key1
- first key.key2
- second key.value
- value to be associated with the specified key pair.
null
if there was no mapping for key.public java.util.Set<X> keySet1()
keySet1
in interface Map2<X,Y,V>
keySet1
in class AbstractMap2<X,Y,V>
public java.util.Set<Y> keySet2()
keySet2
in interface Map2<X,Y,V>
keySet2
in class AbstractMap2<X,Y,V>
public boolean containsKeyPair(java.lang.Object key1, java.lang.Object key2)
true
if this map contains a mapping for the
specified key pair.
This implementation iterates over entrySet()
searching for an
entry with the specified keys. If such an entry is found,
true
is returned. If the iteration terminates without
finding such an entry, false
is returned. Note that this
implementation requires linear time in the size of the map; many
implementations will override this method.
This implementation uses index to check for key pair presence.
containsKeyPair
in interface Map2<X,Y,V>
containsKeyPair
in class AbstractMap2<X,Y,V>
key1
- first keykey2
- second key
true
if this map contains a mapping for the specified
pair of keys.public V remove(X key1, Y key2)
Returns the value to which the map previously associated the keys, or
null if the map contained no mapping for this key pair.
This implementation iterates over entrySet()
searching for an
entry with the specified pair of keys. If such an entry is found,
its value is obtained with its getValue
operation,
the entry is removed from the collection of entries with the iterator's
remove operation, and the saved value is returned. If the
iteration terminates without finding such an entry, null
is
returned. Note that this implementation requires linear time in the
size of the map; many implementations will override this method.
This implementation uses index to retrieve an entry with the specified pair of keys.
remove
in interface Map2<X,Y,V>
remove
in class AbstractMap2<X,Y,V>
key1
- first key.key2
- second key.
public java.util.Map<Y,V> curry1(X key1)
Map<Y,V>
view of Map<Y,Entry<X,Y,Z>> map that is stored in index.
- Specified by:
curry1
in interface Map2<X,Y,V>
- Overrides:
curry1
in class AbstractMap2<X,Y,V>
- Parameters:
key1
- X
- Returns:
- Map
resulting map.
public java.util.Map<X,V> curry2(Y key2)
Map<X,V>
view of Map<Y,Entry<X,Y,Z>> map that is stored in index.
- Specified by:
curry2
in interface Map2<X,Y,V>
- Overrides:
curry2
in class AbstractMap2<X,Y,V>
- Parameters:
key2
- X
- Returns:
- Map
resulting map.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |