Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 73220x 73220x 428527x 80540x 106x 45x | // The reversed view of a linked hash map: the same state walked from the back, so changes show in
// both and the view's ends are the map's ends swapped.
import type { SequencedMap } from '../../interfaces/sequenced-map'
import type { LinkedHashMapEngine } from '../engines/linked-hash-map-engine'
import { AbstractLinkedMap } from '../skeletons/abstract-linked-map'
/**
* A live view of a linked hash map in the opposite order. Reversing it returns the map.
*
* @internal
*/
export class ReversedLinkedHashMap<K, V> extends AbstractLinkedMap<K, V> {
private readonly source: LinkedHashMapEngine<K, V>
/** @param source - The map to reverse. */
constructor(source: LinkedHashMapEngine<K, V>) {
super(source.state, true)
this.source = source
}
get [Symbol.toStringTag](): string {
return 'ReversedLinkedHashMap'
}
get owner(): SequencedMap<K, V> {
return this
}
opposite(): AbstractLinkedMap<K, V> {
return this.source
}
reversed(): SequencedMap<K, V> {
return this.source.owner
}
}
|