A MutableMap
implemented as a hash map stored in an
Array
of singly linked lists of
Entry
s. Each entry is assigned an
index in the array according to the hash code of its key.
The hash code of a key is defined by Object.hash
.
The stability
of a HashMap
controls its iteration
order:
linked
map has a stable and meaningful order of
iteration. The entries of the map form a linked list,
where new entries are added to the end of the linked
list. Iteration of the map follows this linked list, from
least recently added elements to most recently added
elements.unlinked
map has an unstable iteration order that
may change when the map is modified. The order itself is
not meaningful to a client.The stability is linked
by default.
The management of the backing array is controlled by the
given hashtable
.
no subtypes hierarchy
Constructors | |
HashMap | Source Codeshared HashMap(Stability stability = ..., Hashtable hashtable = ..., {<Key->Item>*} entries = ...) Create a new Parameters:
|
copy | Source Codeshared copy(HashMap<Key,Item> hashMap, Stability stability = ..., Hashtable hashtable = ...) Create a new Parameters:
|
Attributes | |
empty | Source Codeshared actual Boolean empty Determines if the stream is empty, that is to say, if the iterator returns no elements. |
first | Source Codeshared actual <Key->Item>? first The first element returned by the iterator, if any, or
Refines Iterable.first |
hash | Source Codeshared actual Integer hash The hash value of the value, which allows the value to be an element of a hash-based set or key of a hash-based map. Implementations must respect the constraint that:
Therefore, a class which refines In general, Note that when executing on a Java Virtual Machine, the
64-bit |
last | Source Codeshared actual <Key->Item>? last The last element returned by the iterator, if any, or
Refines Iterable.last |
size | Source Codeshared actual Integer size The number of elements returned by the Refines Iterable.size |
Inherited Attributes |
Attributes inherited from: Object |
Attributes inherited from: Collection<Element> |
Attributes inherited from: Correspondence<Key,Item> |
Attributes inherited from: Iterable<Element,Absent> |
Attributes inherited from: Map<Key,Item> |
Methods | |
clear | Source Codeshared actual void clear() Remove every entry from this map, leaving an empty map with no entries. Refines MapMutator.clear |
clone | Source Codeshared actual HashMap<Key,Item> clone() A shallow copy of this collection, that is, a collection with identical elements which does not change if this collection changes. If this collection is immutable, it is acceptable to return a reference to this collection. If this collection is mutable, a newly instantiated collection must be returned. |
contains | Source Codeshared actual Boolean contains(Object entry) Returns For any instance element in c For most
However, it is possible to form a useful |
count | Source Codeshared actual Integer count(Boolean selecting(Key->Item element)) Produces the number of elements in this stream that
satisfy the given predicate function ( Refines Iterable.count |
defines | Source Codeshared actual Boolean defines(Object key) Determines if there is a value defined for the given key. |
each | Source Codeshared actual void each(void step(Key->Item element)) Call the given function ( For example: words.each((word) { print(word.lowercased); print(word.uppercased); }); Has the same effect as the following for (word in words) { print(word.lowercased); print(word.uppercased); } For certain streams this method is highly efficient,
surpassing the performance of Refines Iterable.each |
equals | Source Codeshared actual Boolean equals(Object that) Determine if two values are equal. For any two non-null objects x == y Implementations should respect the constraints that:
Furthermore it is recommended that implementations
ensure that if A class which explicitly refines Note that an implementation of |
get | Source Codeshared actual Item? get(Object key) Returns the value defined for the given key, or For any instance c[key] |
getOrDefault | Source Codeshared actual Item|Default getOrDefault<Default>(Object key, Default default) Returns the item of the entry with the given For maps with non-null items, the expression: map.getOrDefault(key, def) is equivalent to this common idiom: map[key] else def However, when the map has null items, Note that high-quality implementations of Refines Map.getOrDefault |
iterator | Source Codeshared actual Iterator<Key->Item> iterator() An iterator for the elements belonging to this stream. If this is a nonempty stream with type Refines Iterable.iterator |
put | Source Codeshared actual Item? put(Key key, Item item) Set the item associated with the given For any instance c[key] = item |
putAll | Source Codeshared actual void putAll({<Key->Item>*} entries) Add the given Refines MapMutator.putAll |
remove | Source Codeshared actual Item? remove(Key key) Remove the entry associated with the given |
removeEntry | Source Codeshared actual Boolean removeEntry(Key key, Item&Object item) Remove the entry associated with the given Refines MapMutator.removeEntry |
replaceEntry | Source Codeshared actual Boolean replaceEntry(Key key, Item&Object item, Item newItem) |
Inherited Methods |
Methods inherited from: Object |
Methods inherited from: Category<Element> |
Methods inherited from: Collection<Element> |
Methods inherited from: Correspondence<Key,Item> |
Methods inherited from: Iterable<Element,Absent> any() , by() , chain() , collect() , contains() , count() , defaultNullElements() , each() , every() , filter() , find() , findLast() , flatMap() , fold() , follow() , frequencies() , getFromFirst() , group() , indexes() , interpose() , iterator() , locate() , locateLast() , locations() , longerThan() , map() , max() , narrow() , partition() , product() , reduce() , repeat() , scan() , select() , sequence() , shorterThan() , skip() , skipWhile() , sort() , spread() , summarize() , tabulate() , take() , takeWhile() |
Methods inherited from: KeyedCorrespondenceMutator<Key,Item> |
Methods inherited from: Map<Key,Item> |
Methods inherited from: MapMutator<Key,Item> |
Methods inherited from: MutableMap<Key,Item> |