|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.javimmutable.collections.common.AbstractJImmutableMap<K,V>
org.javimmutable.collections.inorder.JImmutableInsertOrderMap<K,V>
K
- V
- @Immutable public class JImmutableInsertOrderMap<K,V>
JImmutableMap implementation that allows iteration over members in the order in which they were inserted into the map. Maintains two parallel data structures, one for sorting and the other for storing entries. Gets are approximately as fast as hash map gets but updates are significantly slower. Iteration is comparable to sorted map iteration.
Use a hash or tree map whenever possible but this class performs well enough for most cases where insertion order is important to an algorithm.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.javimmutable.collections.JImmutableMap |
---|
JImmutableMap.Entry<K,V> |
Field Summary | |
---|---|
static JImmutableInsertOrderMap |
EMPTY
|
Method Summary | ||
---|---|---|
JImmutableInsertOrderMap<K,V> |
assign(K key,
V value)
Sets the value associated with a specific key. |
|
Cursor<JImmutableMap.Entry<K,V>> |
cursor()
|
|
JImmutableInsertOrderMap<K,V> |
delete(K key)
Deletes the entry for the specified key (if any). |
|
JImmutableInsertOrderMap<K,V> |
deleteAll()
|
|
Holder<V> |
find(K key)
Search for a value within the map and return a Holder indicating if the value was found and, if it was found, the value itself. |
|
Holder<JImmutableMap.Entry<K,V>> |
findEntry(K key)
Search for an Entry within the map and return a Holder indicating if the Entry was found and, if it was found, the Entry itself. |
|
V |
getValueOr(K key,
V defaultValue)
Return the value associated with key or defaultValue if no value is associated. |
|
static
|
of()
|
|
int |
size()
Return the number of entries in the map. |
Methods inherited from class org.javimmutable.collections.common.AbstractJImmutableMap |
---|
equals, get, getMap, hashCode, insert, isEmpty, iterator, keysCursor, toString, valuesCursor |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final JImmutableInsertOrderMap EMPTY
Method Detail |
---|
public static <K,V> JImmutableInsertOrderMap<K,V> of()
public V getValueOr(K key, V defaultValue)
Mapped
key
- identifies the value to retrievedefaultValue
- value to return if no entry exists for key
@Nonnull public Holder<V> find(@Nonnull K key)
JImmutableMap
key
- non-null key to search for
@Nonnull public Holder<JImmutableMap.Entry<K,V>> findEntry(@Nonnull K key)
JImmutableMap
key
- non-null key to search for
@Nonnull public JImmutableInsertOrderMap<K,V> assign(@Nonnull K key, V value)
JImmutableMap
key
- non-null keyvalue
- possibly null value
@Nonnull public JImmutableInsertOrderMap<K,V> delete(@Nonnull K key)
JImmutableMap
key
- non-null key
public int size()
JImmutableMap
@Nonnull public JImmutableInsertOrderMap<K,V> deleteAll()
@Nonnull public Cursor<JImmutableMap.Entry<K,V>> cursor()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |