Javolution 6.0.0 java
|
Public Member Functions | |
FastMap () | |
FastMap (Equality<? super K > keyEquality) | |
FastMap (Equality<? super K > keyEquality, Equality<? super V > valueEquality) | |
FastMap< K, V > | atomic () |
FastMap< K, V > | shared () |
FastMap< K, V > | parallel () |
FastMap< K, V > | sequential () |
FastMap< K, V > | unmodifiable () |
FastSet< K > | keySet () |
FastCollection< V > | values () |
FastSet< Entry< K, V > > | entrySet () |
void | perform (Consumer<? extends Map< K, V >> action) |
void | update (Consumer<? extends Map< K, V >> action) |
int | size () |
boolean | isEmpty () |
boolean | containsKey (Object key) |
boolean | containsValue (Object value) |
V | get (Object key) |
V | put (K key, V value) |
void | putAll (Map<? extends K, ? extends V > map) |
V | remove (Object key) |
void | clear () |
V | putIfAbsent (K key, V value) |
boolean | remove (Object key, Object value) |
boolean | replace (K key, V oldValue, V newValue) |
V | replace (K key, V value) |
FastMap< K, V > | putAll (FastMap<? extends K, ? extends V > that) |
String | toString () |
Protected Member Functions | |
FastMap (MapService< K, V > service) | |
MapService< K, V > | service () |
Package Functions | |
public< T extends Map< K, V > > Immutable< T > | toImmutable () |
Private Attributes | |
final MapService< K, V > | service |
Static Private Attributes | |
static final long | serialVersionUID = 0x600L |
A high-performance hash map with real-time behavior. Related to FastCollection, fast map supports various views.
The iteration order over the map keys, values or entries is deterministic (unlike java.util.HashMap). It is either the insertion order (default) or the key order for the FastSortedMap subclass. This class permits
keys.
Fast maps can advantageously replace any of the standard java.util
maps.
[code] FastMap<Foo, Bar> hashMap = new FastMap<Foo, Bar>(); FastMap<Foo, Bar> concurrentHashMap = new FastMap<Foo, Bar>().shared(); // FastMap implements ConcurrentMap interface. FastMap<Foo, Bar> linkedHashMap = new FastMap<Foo, Bar>(); // Deterministic iteration order (insertion order). FastMap<Foo, Bar> treeMap = new FastSortedMap<Foo, Bar>(); FastMap<Foo, Bar> concurrentSkipListMap = new FastSortedMap<Foo, Bar>().shared(); FastMap<Foo, Bar> identityHashMap = new FastMap<Foo, Bar>(Equalities.IDENTITY); [/code]
and adds more ...
[code] FastMap<Foo, Bar> atomicMap = new FastMap<Foo, Bar>().atomic(); // Mutex-free access, all updates (e.g. putAll) atomics (unlike ConcurrentHashMap). FastMap<Foo, Bar> atomicTree = new FastSortedMap<Foo, Bar>().atomic(); // Mutex-free access, all updates (e.g. putAll) atomics. FastMap<Foo, Bar> parallelMap = new FastMap<Foo, Bar>().parallel(); // Map actions (perform/update) performed concurrently. FastMap<Foo, Bar> linkedConcurrentHashMap = new FastMap<Foo, Bar>().shared(); // No equivalent in java.util ! FastMap<String, Bar> lexicalHashMap = new FastMap<String, Bar>(Equalities.LEXICAL); // Allows for value retrieval using any CharSequence key. FastMap<String, Bar> fastStringHashMap = new FastMap<String, Bar>(Equalities.LEXICAL_FAST); // Same with faster hashcode calculations. ... [/code]
Of course all views (entry, key, values) over a fast map are fast collections and allow parallel processing. [code] Consumer<Collection<String>> removeNull = new Consumer<Collection<String>>() {
public void accept(Collection<String> view) { Iterator<String> it = view.iterator(); while (it.hasNext()) { if (it.next() == null) it.remove(); } } }; FastMap<Person, String> names = ... names.values().update(removeNull); // Remove all entries with null values. names.atomic().values().update(removeNull); // Same but performed atomically. names.parallel().values().update(removeNull); // Same but performed in parallel. [/code]
Definition at line 97 of file FastMap.java.
javolution.util.FastMap< K, V >.FastMap | ( | ) |
Creates an empty fast map.
Definition at line 110 of file FastMap.java.
javolution.util.FastMap< K, V >.FastMap | ( | Equality<? super K > | keyEquality | ) |
Creates an empty fast map using the specified comparator for keys equality.
Definition at line 118 of file FastMap.java.
javolution.util.FastMap< K, V >.FastMap | ( | Equality<? super K > | keyEquality, |
Equality<? super V > | valueEquality | ||
) |
Creates an empty fast map using the specified comparators for keys equality and values equality.
Definition at line 126 of file FastMap.java.
|
protected |
Creates a map backed up by the specified service implementation.
Definition at line 134 of file FastMap.java.
FastMap<K, V> javolution.util.FastMap< K, V >.atomic | ( | ) |
Returns an atomic view over this map. All operations that write or access multiple elements in the map (such as putAll(), keySet().retainAll(), ...) are atomic. Iterators on atomic collections are thread-safe (no ConcurrentModificationException possible).
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 150 of file FastMap.java.
void javolution.util.FastMap< K, V >.clear | ( | ) |
Removes all this map's entries.
Definition at line 343 of file FastMap.java.
boolean javolution.util.FastMap< K, V >.containsKey | ( | Object | key | ) |
Indicates if this map contains the specified key.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 301 of file FastMap.java.
boolean javolution.util.FastMap< K, V >.containsValue | ( | Object | value | ) |
Indicates if this map contains the specified value.
Definition at line 308 of file FastMap.java.
FastSet<Entry<K, V> > javolution.util.FastMap< K, V >.entrySet | ( | ) |
Returns a set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. The set support adding/removing entries. As far as the set is concerned, two entries are considered equals if they have the same keys regardless of their values.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 236 of file FastMap.java.
Referenced by javolution.util.FastMap< Object, javolution.util.Index >.toString().
V javolution.util.FastMap< K, V >.get | ( | Object | key | ) |
Returns the value for the specified key.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 315 of file FastMap.java.
Referenced by javolution.context.internal.LocalContextImpl.getValue(), and javolution.xml.internal.XMLContextImpl.searchFormat().
boolean javolution.util.FastMap< K, V >.isEmpty | ( | ) |
Indicates if this map is empty
Definition at line 294 of file FastMap.java.
FastSet<K> javolution.util.FastMap< K, V >.keySet | ( | ) |
Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. The set supports adding new keys for which the corresponding entry value is always
.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 206 of file FastMap.java.
FastMap<K, V> javolution.util.FastMap< K, V >.parallel | ( | ) |
Returns a parallel map. Parallel maps affect closure-based operations over the map or any of its views (entry, key, values, etc.), all others operations behaving the same. Parallel maps do not require this map to be thread-safe (internal synchronization).
Definition at line 178 of file FastMap.java.
void javolution.util.FastMap< K, V >.perform | ( | Consumer<? extends Map< K, V >> | action | ) |
Executes the specified read-only action on this map. That logic may be performed concurrently on sub-maps if this map is parallel.
action | the read-only action. |
UnsupportedOperationException | if the action tries to update this map. |
ClassCastException | if the action type is not compatible with this map (e.g. action on sorted map and this is a hash map). |
Definition at line 258 of file FastMap.java.
V javolution.util.FastMap< K, V >.put | ( | K | key, |
V | value | ||
) |
Associates the specified value with the specified key.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 322 of file FastMap.java.
Referenced by javolution.xml.internal.XMLContextImpl.searchFormat(), javolution.xml.internal.XMLContextImpl.setFormat(), and javolution.context.internal.LocalContextImpl.supersede().
FastMap<K, V> javolution.util.FastMap< K, V >.putAll | ( | FastMap<? extends K, ? extends V > | that | ) |
Returns this map with the specified map's entries added.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 387 of file FastMap.java.
void javolution.util.FastMap< K, V >.putAll | ( | Map<? extends K, ? extends V > | map | ) |
Adds the specified map entries to this map.
Definition at line 329 of file FastMap.java.
Referenced by javolution.util.FastMap< Object, javolution.util.Index >.putAll().
V javolution.util.FastMap< K, V >.putIfAbsent | ( | K | key, |
V | value | ||
) |
Associates the specified value with the specified key only if the specified key has no current mapping.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 355 of file FastMap.java.
V javolution.util.FastMap< K, V >.remove | ( | Object | key | ) |
Removes the entry for the specified key.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 336 of file FastMap.java.
boolean javolution.util.FastMap< K, V >.remove | ( | Object | key, |
Object | value | ||
) |
Removes the entry for a key only if currently mapped to a given value.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 362 of file FastMap.java.
boolean javolution.util.FastMap< K, V >.replace | ( | K | key, |
V | oldValue, | ||
V | newValue | ||
) |
Replaces the entry for a key only if currently mapped to a given value.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 369 of file FastMap.java.
V javolution.util.FastMap< K, V >.replace | ( | K | key, |
V | value | ||
) |
Replaces the entry for a key only if currently mapped to some value.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 376 of file FastMap.java.
FastMap<K, V> javolution.util.FastMap< K, V >.sequential | ( | ) |
Returns a sequential view of this collection. Using this view, all closure-based iterations are performed sequentially.
Definition at line 186 of file FastMap.java.
|
protected |
Returns this map service implementation.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 420 of file FastMap.java.
FastMap<K, V> javolution.util.FastMap< K, V >.shared | ( | ) |
Returns a thread-safe view over this map. The shared view allows for concurrent read as long as there is no writer. The default implementation is based on readers-writers locks giving priority to writers. Iterators on shared collections are thread-safe (no ConcurrentModificationException possible).
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 164 of file FastMap.java.
int javolution.util.FastMap< K, V >.size | ( | ) |
Returns the number of entries/keys/values in this map.
Definition at line 287 of file FastMap.java.
|
package |
Returns an immutable reference over this map. The immutable value is an unmodifiable view of this map for which the caller guarantees that no change will ever be made (e.g. there is no reference left to the original map).
Definition at line 398 of file FastMap.java.
String javolution.util.FastMap< K, V >.toString | ( | ) |
Returns the string representation of this map entries.
Definition at line 413 of file FastMap.java.
FastMap<K, V> javolution.util.FastMap< K, V >.unmodifiable | ( | ) |
Returns an unmodifiable view over this map. Any attempt to modify the map through this view will result into a java.lang.UnsupportedOperationException being raised.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 195 of file FastMap.java.
Referenced by javolution.util.FastMap< Object, javolution.util.Index >.toImmutable().
void javolution.util.FastMap< K, V >.update | ( | Consumer<? extends Map< K, V >> | action | ) |
Executes the specified update action on this map. That logic may be performed concurrently on sub-maps if this map is parallel. For atomic maps the update is atomic (either concurrent readers see the full result of the action or nothing).
action | the update action. |
ClassCastException | if the action type is not compatible with this map (e.g. action on sorted map and this is a hash map). |
Definition at line 276 of file FastMap.java.
FastCollection<V> javolution.util.FastMap< K, 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, and vice-versa. The collection supports removing values (hence entries) but not adding new values.
Definition at line 216 of file FastMap.java.
|
staticprivate |
Definition at line 100 of file FastMap.java.
Referenced by javolution.util.FastMap< Object, javolution.util.Index >.values().
|
private |
Holds the actual map service implementation.
Reimplemented in javolution.util.FastSortedMap< K, V >.
Definition at line 105 of file FastMap.java.
Referenced by javolution.util.FastMap< Object, javolution.util.Index >.atomic(), javolution.util.FastMap< Object, javolution.util.Index >.clear(), javolution.util.FastMap< Object, javolution.util.Index >.containsKey(), javolution.util.FastMap< Object, javolution.util.Index >.containsValue(), javolution.util.FastMap< Object, javolution.util.Index >.entrySet(), javolution.util.FastMap< Object, javolution.util.Index >.FastMap(), javolution.util.FastMap< Object, javolution.util.Index >.get(), javolution.util.FastMap< Object, javolution.util.Index >.isEmpty(), javolution.util.FastMap< Object, javolution.util.Index >.keySet(), javolution.util.FastMap< Object, javolution.util.Index >.parallel(), javolution.util.FastMap< Object, javolution.util.Index >.perform(), javolution.util.FastMap< Object, javolution.util.Index >.put(), javolution.util.FastMap< Object, javolution.util.Index >.putAll(), javolution.util.FastMap< Object, javolution.util.Index >.putIfAbsent(), javolution.util.FastMap< Object, javolution.util.Index >.remove(), javolution.util.FastMap< Object, javolution.util.Index >.replace(), javolution.util.FastMap< Object, javolution.util.Index >.sequential(), javolution.util.FastMap< Object, javolution.util.Index >.service(), javolution.util.FastMap< Object, javolution.util.Index >.shared(), javolution.util.FastMap< Object, javolution.util.Index >.size(), javolution.util.FastMap< Object, javolution.util.Index >.unmodifiable(), javolution.util.FastMap< Object, javolution.util.Index >.update(), and javolution.util.FastMap< Object, javolution.util.Index >.values().