|
||||||||||
| 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.TreeMap<X,Y>
org.knowceans.map.BijectiveTreeMap<X,Y>
public class BijectiveTreeMap<X,Y>
BijectiveHashMap is a TreeMap that bijectively assigns unique keys to unique values and vice versa. The inverse mapping is done by a TreeMap that maps values to keys and sorts in the natural order of keys. With getInverse(), a key can be found from the value without the search overhead of a value search. The bijective property constrains all input to obey unique keys AND unique values, while permitting the null element.
In relational terms, this class implements a 1:1 relation.
As the underlying TreeMap has O(log(n)) get() and put() complexity, it can be used to identify numerical dimensions, such as the rows and columns of a matrix, much more conveniently than by array lookups (which would require array search for the inverse), however with some additive overhead over array index lookups.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.util.AbstractMap |
|---|
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
java.util.Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
BijectiveTreeMap()
|
|
BijectiveTreeMap(java.util.Comparator<? super X> forward)
initialise with a comparator on the forward relation |
|
BijectiveTreeMap(java.util.Comparator<? super X> forward,
java.util.Comparator<? super Y> backward)
initialise with comparators on the forward and backward relations |
|
BijectiveTreeMap(IBijectiveMap<? extends X,? extends Y> t)
|
|
BijectiveTreeMap(java.util.Map<? extends X,? extends Y> t)
|
|
| Method Summary | |
|---|---|
java.util.TreeMap<Y,X> |
getInverse()
|
X |
getInverse(Y val)
gets key for a value. |
java.util.Set<Y> |
getValues()
returns the keys of the inverse map. |
static void |
main(java.lang.String[] args)
|
Y |
put(X key,
Y val)
put key-value pair into the map. |
Y |
remove(java.lang.Object key)
removes the key and its value from the map. |
java.util.Collection<Y> |
values()
|
| Methods inherited from class java.util.TreeMap |
|---|
ceilingEntry, ceilingKey, clear, clone, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, putAll, size, subMap, subMap, tailMap, tailMap |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, isEmpty, toString |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, putAll, size |
| Constructor Detail |
|---|
public BijectiveTreeMap()
public BijectiveTreeMap(java.util.Map<? extends X,? extends Y> t)
public BijectiveTreeMap(IBijectiveMap<? extends X,? extends Y> t)
public BijectiveTreeMap(java.util.Comparator<? super X> forward)
forward -
public BijectiveTreeMap(java.util.Comparator<? super X> forward,
java.util.Comparator<? super Y> backward)
forward - | Method Detail |
|---|
public static void main(java.lang.String[] args)
public Y put(X key,
Y val)
put in interface java.util.Map<X,Y>put in class java.util.TreeMap<X,Y>public Y remove(java.lang.Object key)
remove in interface java.util.Map<X,Y>remove in class java.util.TreeMap<X,Y>public X getInverse(Y val)
getInverse in interface IBijectiveMap<X,Y>val -
public java.util.TreeMap<Y,X> getInverse()
getInverse in interface IBijectiveMap<X,Y>public java.util.Set<Y> getValues()
public java.util.Collection<Y> values()
values in interface java.util.Map<X,Y>values in interface java.util.SortedMap<X,Y>values in class java.util.TreeMap<X,Y>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||