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 | 10716x 10716x 8007x 264x 57x | // The reversed view of a linked hash set: the same state, walked from the back,
// so changes show in both and the view's ends are the set's ends swapped.
import type { SequencedSet } from '../../interfaces/sequenced-set'
import type { LinkedHashSetEngine } from '../engines/linked-hash-set-engine'
import { AbstractLinkedSet } from '../skeletons/abstract-linked-set'
/**
* A live view of a linked hash set in the opposite order. Reversing it returns the set.
*
* @internal
*/
export class ReversedLinkedHashSet<E> extends AbstractLinkedSet<E> {
private readonly source: LinkedHashSetEngine<E>
/** @param source - The set to reverse. */
constructor(source: LinkedHashSetEngine<E>) {
super(source.state, true)
this.source = source
}
get [Symbol.toStringTag](): string {
return 'ReversedLinkedHashSet'
}
get owner(): SequencedSet<E> {
return this
}
reversed(): SequencedSet<E> {
return this.source.owner
}
}
|