|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jjoost.collections.bimaps.AbstractBiMap<K,V,Map<K,V>,Map<V,K>>
org.jjoost.collections.bimaps.BiMapOneToOne<K,V>
public class BiMapOneToOne<K,V>
| Constructor Summary | |
|---|---|
BiMapOneToOne(Map<K,V> forwards,
Map<V,K> back)
|
|
| Method Summary | |
|---|---|
V |
apply(K v)
Returns the result of applying the function to the parameter |
Map<K,V> |
copy()
Returns a copy of the map. |
V |
ensureAndGet(K key,
Factory<? extends V> putIfNotPresent)
Equivalent to putIfAbsent(key, putIfNotPresent), except that instead of returning the value previously associated with the key, returns the value associated with the key as the method is exiting; i.e. |
V |
ensureAndGet(K key,
Function<? super K,? extends V> putIfNotPresent)
Equivalent to putIfAbsent(key, putIfNotPresent.create(key)), except that putIfNotPresent.create() is only executed if there is no
key associated with the value. |
Set<java.util.Map.Entry<K,V>> |
entries()
Returns a set representing all the key->value pairs in this map. |
V |
get(K key)
A convenience method, equivalent to first(key) |
Map<V,K> |
inverse()
Returns a map representing the inverse function of this map. |
Set<K> |
keys()
Returns a set representing all the keys in the domain of this map. |
V |
putIfAbsent(K key,
Function<? super K,? extends V> putIfNotPresent)
Equivalent to putIfAbsent(key, putIfNotPresent.create()), except that
putIfNotPresent.create() is only executed if there is no key associated
with the value. |
int |
size()
A convenience method, equivalent to both totalCount() and uniqueKeyCount() |
UnitarySet<V> |
values(K key)
Returns a set representing the values associated with the provided key in this map. |
| Methods inherited from class org.jjoost.collections.bimaps.AbstractBiMap |
|---|
add, clear, clearAndReturn, contains, contains, count, count, entries, first, isEmpty, list, permitsDuplicateKeys, put, putIfAbsent, remove, remove, removeAndReturn, removeAndReturn, removeAndReturnFirst, shrink, totalCount, uniqueKeyCount, values |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.jjoost.collections.Map |
|---|
put, putIfAbsent |
| Methods inherited from interface org.jjoost.collections.AnyMap |
|---|
add, clear, clearAndReturn, remove, remove, removeAndReturn, removeAndReturn, removeAndReturnFirst, shrink, values |
| Methods inherited from interface org.jjoost.collections.AnyReadMap |
|---|
contains, contains, count, count, entries, first, isEmpty, list, permitsDuplicateKeys, totalCount, uniqueKeyCount |
| Constructor Detail |
|---|
public BiMapOneToOne(Map<K,V> forwards,
Map<V,K> back)
| Method Detail |
|---|
public Map<K,V> copy()
AnyMap
copy in interface AnyMap<K,V>copy in interface Map<K,V>public Map<V,K> inverse()
AnyMap
inverse in interface AnyMap<K,V>inverse in class AbstractBiMap<K,V,Map<K,V>,Map<V,K>>public Set<java.util.Map.Entry<K,V>> entries()
AnyReadMapListMap this will be a MultiSet. This set
should always reflect changes to the map, and changes to the set should
be reflected in the map also. Otherwise, this set should behave exactly
as a regular set does.
entries in interface AnyMap<K,V>entries in interface AnyReadMap<K,V>entries in interface Map<K,V>public Set<K> keys()
AnyReadMapMultiMap or ListMap this will be a
MultiSet. This set should always reflect changes to the map,
and changes to the set should be reflected in the map also. Otherwise,
this set should behave exactly as a regular set does. The key equality used
by this map can be obtained from this set.
Depending on the implementation of map, this key set may contain every occurrence of equal keys provided to the map, or may contain a subset thereof with repetitions to bring the number of occurrences in line with the number provided.
Note that the put() methods on this set will always fail,
because no value can be provided to update the map with.
keys in interface AnyMap<K,V>keys in interface AnyReadMap<K,V>keys in interface Map<K,V>
public V ensureAndGet(K key,
Factory<? extends V> putIfNotPresent)
Map
ensureAndGet in interface Map<K,V>key - the keyputIfNotPresent - the put if not present
public V ensureAndGet(K key,
Function<? super K,? extends V> putIfNotPresent)
MapputIfNotPresent.create() is only executed if there is no
key associated with the value. In concurrent maps this is not a
guarantee, but a best effort, as it is possible for another thread to set
a value for the key after this has executed but before the record can be
inserted
ensureAndGet in interface Map<K,V>key - the keyputIfNotPresent - put if not present
public V get(K key)
Map
get in interface Map<K,V>key - the key
public V putIfAbsent(K key,
Function<? super K,? extends V> putIfNotPresent)
MapputIfAbsent(key, putIfNotPresent.create()), except that
putIfNotPresent.create() is only executed if there is no key associated
with the value. In concurrent maps this is not a guarantee, but a best effort,
as it is possible for another thread to set a value for the key after this has executed
but before the record can be inserted.
putIfAbsent in interface Map<K,V>key - the keyputIfNotPresent - the put if not present
public int size()
MaptotalCount() and uniqueKeyCount()
size in interface Map<K,V>public V apply(K v)
Function
apply in interface Function<K,V>v - something of type domain
public UnitarySet<V> values(K key)
AnyReadMap
Note that in a regular (scalar) map the set returned will be a
UnitarySet, which contains at most one value.
put() operations on such a set will override any existing
value regardless of if it is equal to the one already present.
values in interface AnyMap<K,V>values in interface AnyReadMap<K,V>values in interface Map<K,V>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||