Javolution 6.0.0 java
javolution.util.FastSortedMap< K, V > Class Template Reference
Inheritance diagram for javolution.util.FastSortedMap< K, V >:
[legend]
Collaboration diagram for javolution.util.FastSortedMap< K, V >:
[legend]

Public Member Functions

 FastSortedMap ()
 
 FastSortedMap (Equality<? super K > keyComparator)
 
 FastSortedMap (Equality<? super K > keyComparator, Equality<? super V > valueComparator)
 
FastSortedMap< K, V > atomic ()
 
FastSortedMap< K, V > shared ()
 
FastSortedMap< K, V > unmodifiable ()
 
FastSortedSet< Entry< K, V > > entrySet ()
 
FastSortedSet< K > keySet ()
 
FastSortedMap< K, V > subMap (K fromKey, K toKey)
 
FastSortedMap< K, V > headMap (K toKey)
 
FastSortedMap< K, V > tailMap (K fromKey)
 
boolean containsKey (Object key)
 
get (Object key)
 
put (K key, V value)
 
remove (Object key)
 
putIfAbsent (K key, V value)
 
boolean remove (Object key, Object value)
 
boolean replace (K key, V oldValue, V newValue)
 
replace (K key, V value)
 
firstKey ()
 
lastKey ()
 
Comparator<? super K > comparator ()
 
FastSortedMap< K, V > putAll (FastMap<? extends K, ? extends V > that)
 
FastMap< K, V > parallel ()
 
FastMap< K, V > sequential ()
 
FastCollection< V > values ()
 
void perform (Consumer<? extends Map< K, V >> action)
 
void update (Consumer<? extends Map< K, V >> action)
 
int size ()
 
boolean isEmpty ()
 
boolean containsValue (Object value)
 
void putAll (Map<? extends K, ? extends V > map)
 
void clear ()
 
String toString ()
 

Protected Member Functions

 FastSortedMap (SortedMapService< K, V > service)
 
SortedMapService< K, V > service ()
 

Package Functions

public< T extends Map< K, V > > Immutable< T > toImmutable ()
 

Static Private Attributes

static final long serialVersionUID = 0x600L
 

Detailed Description

A high-performance sorted map with real-time behavior.

This map provides a total ordering based on the keys natural order or using custom comparators.

Author
Jean-Marie Dautelle
Version
6.0, July 21, 2013

Definition at line 34 of file FastSortedMap.java.

Constructor & Destructor Documentation

◆ FastSortedMap() [1/4]

Creates an empty sorted map ordered on keys natural order.

Definition at line 42 of file FastSortedMap.java.

42  {
43  this(Equalities.STANDARD);
44  }

References javolution.util.function.Equalities.STANDARD.

◆ FastSortedMap() [2/4]

javolution.util.FastSortedMap< K, V >.FastSortedMap ( Equality<? super K >  keyComparator)

Creates an empty sorted map ordered using the specified comparator for order.

Definition at line 50 of file FastSortedMap.java.

50  {
51  this(keyComparator, Equalities.STANDARD);
52  }

References javolution.util.function.Equalities.STANDARD.

◆ FastSortedMap() [3/4]

javolution.util.FastSortedMap< K, V >.FastSortedMap ( Equality<? super K >  keyComparator,
Equality<? super V >  valueComparator 
)

Creates an empty sorted map ordered using the specified key comparator for order and value comparator for values equality.

Definition at line 58 of file FastSortedMap.java.

59  {
60  super(new FastSortedMapImpl<K, V>(keyComparator, valueComparator));
61  }

◆ FastSortedMap() [4/4]

javolution.util.FastSortedMap< K, V >.FastSortedMap ( SortedMapService< K, V >  service)
protected

Creates a sorted map backed up by the specified service implementation.

Definition at line 66 of file FastSortedMap.java.

66  {
67  super(service);
68  }

References javolution.util.FastSortedMap< K, V >.service().

Here is the call graph for this function:

Member Function Documentation

◆ atomic()

FastSortedMap<K, V> javolution.util.FastSortedMap< 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 from javolution.util.FastMap< K, V >.

Definition at line 75 of file FastSortedMap.java.

75  {
76  return new FastSortedMap<K, V>(new AtomicSortedMapImpl<K, V>(service()));
77  }

References javolution.util.FastSortedMap< K, V >.service().

Here is the call graph for this function:

◆ clear()

void javolution.util.FastMap< K, V >.clear ( )
inherited

Removes all this map's entries.

Definition at line 343 of file FastMap.java.

343  {
344  service.clear();
345  }

◆ comparator()

Comparator<? super K> javolution.util.FastSortedMap< K, V >.comparator ( )

Returns the comparator used to order the keys in this map (never null).

Definition at line 188 of file FastSortedMap.java.

188  {
189  return keySet().comparator();
190  }

References javolution.util.FastSortedMap< K, V >.keySet().

Here is the call graph for this function:

◆ containsKey()

boolean javolution.util.FastSortedMap< K, V >.containsKey ( Object  key)

Indicates if this map contains the specified key.

Reimplemented from javolution.util.FastMap< K, V >.

Definition at line 124 of file FastSortedMap.java.

124  {
125  return super.containsKey(key);
126  }

◆ containsValue()

boolean javolution.util.FastMap< K, V >.containsValue ( Object  value)
inherited

Indicates if this map contains the specified value.

Definition at line 308 of file FastMap.java.

308  {
309  return service.containsValue(value);
310  }

◆ entrySet()

FastSortedSet<Entry<K, V> > javolution.util.FastSortedMap< 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 from javolution.util.FastMap< K, V >.

Definition at line 91 of file FastSortedMap.java.

91  {
92  return new FastSortedSet<Entry<K, V>>(service().entrySet());
93  }

References javolution.util.FastSortedMap< K, V >.service().

Here is the call graph for this function:

◆ firstKey()

K javolution.util.FastSortedMap< K, V >.firstKey ( )

Returns the first (lowest) key currently in this map.

Definition at line 176 of file FastSortedMap.java.

176  {
177  return service().firstKey();
178  }

References javolution.util.FastSortedMap< K, V >.service().

Referenced by javolution.util.FastSortedMap< K, V >.headMap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get()

V javolution.util.FastSortedMap< K, V >.get ( Object  key)

Returns the value for the specified key.

Reimplemented from javolution.util.FastMap< K, V >.

Definition at line 130 of file FastSortedMap.java.

130  {
131  return super.get(key);
132  }

◆ headMap()

FastSortedMap<K, V> javolution.util.FastSortedMap< K, V >.headMap ( toKey)

Returns a view of the portion of this map whose keys are strictly less than toKey.

Definition at line 108 of file FastSortedMap.java.

108  {
109  return new FastSortedMap<K, V>(service().subMap(firstKey(), toKey));
110  }

References javolution.util.FastSortedMap< K, V >.firstKey(), javolution.util.FastSortedMap< K, V >.service(), and javolution.util.FastSortedMap< K, V >.subMap().

Here is the call graph for this function:

◆ isEmpty()

boolean javolution.util.FastMap< K, V >.isEmpty ( )
inherited

Indicates if this map is empty

Definition at line 294 of file FastMap.java.

294  {
295  return service.isEmpty();
296  }

◆ 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

null

.

Reimplemented from javolution.util.FastMap< K, V >.

Definition at line 96 of file FastSortedMap.java.

96  {
97  return new FastSortedSet<K>(service().keySet());
98  }

References javolution.util.FastSortedMap< K, V >.service().

Referenced by javolution.util.FastSortedMap< K, V >.comparator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lastKey()

K javolution.util.FastSortedMap< K, V >.lastKey ( )

Returns the last (highest) key currently in this map.

Definition at line 182 of file FastSortedMap.java.

182  {
183  return service().lastKey();
184  }

References javolution.util.FastSortedMap< K, V >.service().

Referenced by javolution.util.FastSortedMap< K, V >.tailMap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parallel()

FastMap<K, V> javolution.util.FastMap< K, V >.parallel ( )
inherited

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).

See also
#perform(Consumer)
#update(Consumer)
FastCollection::parallel()

Definition at line 178 of file FastMap.java.

178  {
179  return new FastMap<K, V>(new ParallelMapImpl<K, V>(service));
180  }

◆ perform()

void javolution.util.FastMap< K, V >.perform ( Consumer<? extends Map< K, V >>  action)
inherited

Executes the specified read-only action on this map. That logic may be performed concurrently on sub-maps if this map is parallel.

Parameters
actionthe read-only action.
Exceptions
UnsupportedOperationExceptionif the action tries to update this map.
ClassCastExceptionif the action type is not compatible with this map (e.g. action on sorted map and this is a hash map).
See also
#update(Consumer)

Definition at line 258 of file FastMap.java.

258  {
259  service().perform((Consumer<MapService<K, V>>) action, service());
260  }

◆ put()

V javolution.util.FastSortedMap< K, V >.put ( key,
value 
)

Associates the specified value with the specified key.

Reimplemented from javolution.util.FastMap< K, V >.

Definition at line 136 of file FastSortedMap.java.

136  {
137  return super.put(key, value);
138  }

◆ putAll() [1/2]

FastSortedMap<K, V> javolution.util.FastSortedMap< K, V >.putAll ( FastMap<? extends K, ? extends V >  that)

Returns this map with the specified map's entries added.

Reimplemented from javolution.util.FastMap< K, V >.

Definition at line 197 of file FastSortedMap.java.

197  {
198  return (FastSortedMap<K, V>) super.putAll(that);
199  }

◆ putAll() [2/2]

void javolution.util.FastMap< K, V >.putAll ( Map<? extends K, ? extends V >  map)
inherited

Adds the specified map entries to this map.

Definition at line 329 of file FastMap.java.

329  {
330  service.putAll(map);
331  }

Referenced by javolution.util.FastMap< Object, javolution.util.Index >.putAll().

Here is the caller graph for this function:

◆ putIfAbsent()

V javolution.util.FastSortedMap< K, V >.putIfAbsent ( key,
value 
)

Associates the specified value with the specified key only if the specified key has no current mapping.

Reimplemented from javolution.util.FastMap< K, V >.

Definition at line 148 of file FastSortedMap.java.

148  {
149  return super.putIfAbsent(key, value);
150  }

◆ remove() [1/2]

V javolution.util.FastSortedMap< K, V >.remove ( Object  key)

Removes the entry for the specified key.

Reimplemented from javolution.util.FastMap< K, V >.

Definition at line 142 of file FastSortedMap.java.

142  {
143  return super.remove(key);
144  }

◆ remove() [2/2]

boolean javolution.util.FastSortedMap< K, V >.remove ( Object  key,
Object  value 
)

Removes the entry for a key only if currently mapped to a given value.

Reimplemented from javolution.util.FastMap< K, V >.

Definition at line 154 of file FastSortedMap.java.

154  {
155  return super.remove(key, value);
156  }

◆ replace() [1/2]

boolean javolution.util.FastSortedMap< K, V >.replace ( key,
oldValue,
newValue 
)

Replaces the entry for a key only if currently mapped to a given value.

Reimplemented from javolution.util.FastMap< K, V >.

Definition at line 160 of file FastSortedMap.java.

160  {
161  return super.replace(key, oldValue, newValue);
162  }

◆ replace() [2/2]

V javolution.util.FastSortedMap< K, V >.replace ( key,
value 
)

Replaces the entry for a key only if currently mapped to some value.

Reimplemented from javolution.util.FastMap< K, V >.

Definition at line 166 of file FastSortedMap.java.

166  {
167  return super.replace(key, value);
168  }

◆ sequential()

FastMap<K, V> javolution.util.FastMap< K, V >.sequential ( )
inherited

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.

186  {
187  return new FastMap<K, V>(new SequentialMapImpl<K, V>(service));
188  }

◆ service()

◆ shared()

FastSortedMap<K, V> javolution.util.FastSortedMap< 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 from javolution.util.FastMap< K, V >.

Definition at line 80 of file FastSortedMap.java.

80  {
81  return new FastSortedMap<K, V>(new SharedSortedMapImpl<K, V>(service()));
82  }

References javolution.util.FastSortedMap< K, V >.service().

Here is the call graph for this function:

◆ size()

int javolution.util.FastMap< K, V >.size ( )
inherited

Returns the number of entries/keys/values in this map.

Definition at line 287 of file FastMap.java.

287  {
288  return service.size();
289  }

◆ subMap()

FastSortedMap<K, V> javolution.util.FastSortedMap< K, V >.subMap ( fromKey,
toKey 
)

Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.

Definition at line 102 of file FastSortedMap.java.

102  {
103  return new FastSortedMap<K, V>(service().subMap(fromKey, toKey));
104  }

References javolution.util.FastSortedMap< K, V >.service().

Referenced by javolution.util.FastSortedMap< K, V >.headMap(), and javolution.util.FastSortedMap< K, V >.tailMap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tailMap()

FastSortedMap<K, V> javolution.util.FastSortedMap< K, V >.tailMap ( fromKey)

Returns a view of the portion of this map whose keys are greater than or equal to fromKey.

Definition at line 114 of file FastSortedMap.java.

114  {
115  return new FastSortedMap<K, V>(service().subMap(fromKey, lastKey()));
116  }

References javolution.util.FastSortedMap< K, V >.lastKey(), javolution.util.FastSortedMap< K, V >.service(), and javolution.util.FastSortedMap< K, V >.subMap().

Here is the call graph for this function:

◆ toImmutable()

public<T extends Map<K, V> > Immutable<T> javolution.util.FastMap< K, V >.toImmutable ( )
packageinherited

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.

398  {
399  return new Immutable<T>() {
400  @SuppressWarnings("unchecked")
401  final T value = (T) unmodifiable();
402 
403  @Override
404  public T value() {
405  return value;
406  }
407  };
408  }

◆ toString()

String javolution.util.FastMap< K, V >.toString ( )
inherited

Returns the string representation of this map entries.

Definition at line 413 of file FastMap.java.

413  {
414  return TextContext.getFormat(FastCollection.class).format(entrySet());
415  }

◆ unmodifiable()

FastSortedMap<K, V> javolution.util.FastSortedMap< 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 from javolution.util.FastMap< K, V >.

Definition at line 85 of file FastSortedMap.java.

85  {
86  return new FastSortedMap<K, V>(new UnmodifiableSortedMapImpl<K, V>(
87  service()));
88  }

References javolution.util.FastSortedMap< K, V >.service().

Here is the call graph for this function:

◆ update()

void javolution.util.FastMap< K, V >.update ( Consumer<? extends Map< K, V >>  action)
inherited

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).

Parameters
actionthe update action.
Exceptions
ClassCastExceptionif the action type is not compatible with this map (e.g. action on sorted map and this is a hash map).
See also
#perform(Consumer)

Definition at line 276 of file FastMap.java.

276  {
277  service().update((Consumer<MapService<K, V>>) action, service());
278  }

◆ values()

FastCollection<V> javolution.util.FastMap< K, V >.values ( )
inherited

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.

216  {
217  return new FastCollection<V>() {
218  private static final long serialVersionUID = 0x600L; // Version.
219  private final CollectionService<V> serviceValues = service.values();
220 
221  @Override
222  protected CollectionService<V> service() {
223  return serviceValues;
224  }
225  };
226  }

Member Data Documentation

◆ serialVersionUID

final long javolution.util.FastSortedMap< K, V >.serialVersionUID = 0x600L
staticprivate

Definition at line 37 of file FastSortedMap.java.


The documentation for this class was generated from the following file:
javolution.util.FastSortedMap.firstKey
K firstKey()
Definition: FastSortedMap.java:176
javolution.util.FastSortedMap.service
SortedMapService< K, V > service()
Definition: FastSortedMap.java:202
javolution.util.FastMap.entrySet
FastSet< Entry< K, V > > entrySet()
Definition: FastMap.java:236
javolution.util.FastMap.serialVersionUID
static final long serialVersionUID
Definition: FastMap.java:100
javolution.util.FastSortedMap.subMap
FastSortedMap< K, V > subMap(K fromKey, K toKey)
Definition: FastSortedMap.java:102
javolution.util.FastMap.service
final MapService< K, V > service
Definition: FastMap.java:105
javolution.util.FastSortedMap.keySet
FastSortedSet< K > keySet()
Definition: FastSortedMap.java:96
javolution.util.FastMap.unmodifiable
FastMap< K, V > unmodifiable()
Definition: FastMap.java:195
javolution.util.FastSortedMap.lastKey
K lastKey()
Definition: FastSortedMap.java:182