Hash-based map that preserves insertion order via a doubly-linked list.
Time O(1), Space O(1)
examples will be generated by unit test Copy
examples will be generated by unit test
Create a LinkedHashMap and optionally bulk-insert entries.
Optional
Iterable of entries or raw elements to insert.
Options: hash functions and optional record-to-entry converter.
New LinkedHashMap instance.
Time O(N), Space O(N)
Get the first [key, value] pair.
First entry or undefined when empty.
Get the head node (first entry) sentinel link.
Head node or sentinel.
Get the last [key, value] pair.
Last entry or undefined when empty.
Get the internal record for non-object keys.
Record of hash→node.
Get the hash function for object/weak keys.
Object-hash function.
Total number of entries.
Entry count.
Get the tail node (last entry) sentinel link.
Tail node or sentinel.
Protected
Underlying iterator for the default iteration protocol.
Iterator of [K, V].
[K, V]
Time O(n), Space O(1)
Default iterator yielding [key, value] entries.
[key, value]
Rest
Time O(n) to iterate, Space O(1)
Get the value at a given index in insertion order.
Zero-based index.
Value at the index.
Time O(N), Space O(1)
Iterate from head → tail.
Iterator of [key, value].
Remove all entries.
Time O(n) typical, Space O(1)
Deep clone preserving the concrete subtype.
A new instance of the same concrete class (this type).
this
Time O(n) typical, Space O(n)
Delete the entry at a given index.
True if removed.
Delete the first entry that matches a predicate.
Function (key, value, index, map) → boolean to decide deletion.
True if an entry was removed.
Iterate over [key, value] pairs (may yield undefined values).
undefined
Iterator of [K, V | undefined].
[K, V | undefined]
Test whether all entries satisfy the predicate.
(key, value, index, self) => boolean.
(key, value, index, self) => boolean
Optional this for callback.
true if all pass; otherwise false.
true
false
Filter entries and return the same-species structure.
Time O(n), Space O(n)
Find the first entry that matches a predicate.
Matching [key, value] or undefined.
Visit each entry, left-to-right.
(key, value, index, self) => void.
(key, value, index, self) => void
Get the value under a key.
Key to look up.
Value or undefined.
Time O(n) generic, Space O(1)
Whether the given key exists.
Key to test.
true if found; otherwise false.
Whether there exists an entry with the given value.
Value to test.
Whether there are no entries.
true if empty; false otherwise.
Time O(1) typical, Space O(1)
Iterate over keys only.
Iterator of keys.
Map each entry to a new [key, value] pair and preserve order.
Mapping function (key, value, index, map) → [newKey, newValue].
Value for this inside the callback.
A new map of the same class with transformed entries.
Print a human-friendly representation to the console.
Reduce entries into a single accumulator.
(acc, value, key, index, self) => acc.
(acc, value, key, index, self) => acc
Initial accumulator.
Final accumulator.
Iterate from tail → head.
Insert or replace a single entry; preserves insertion order.
Key.
Value.
True when the operation succeeds.
Test whether any entry satisfies the predicate.
true if any passes; otherwise false.
Visualize the iterable as an array of [key, value] pairs (or a custom string).
Array of entries (default) or a string.
Iterate over values only.
Iterator of values.
Hash-based map that preserves insertion order via a doubly-linked list.
Remarks
Time O(1), Space O(1)
Example