| 55 | } |
| 56 | |
| 57 | class MutableHashMapIterator<K, V> implements IterableIterator<[K, V]> { |
| 58 | readonly referentialIterator: Iterator<[K, V]> |
| 59 | bucketIterator: Iterator<[K, V]> | undefined |
| 60 | |
| 61 | constructor(readonly self: MutableHashMap<K, V>) { |
| 62 | this.referentialIterator = self.referential[Symbol.iterator]() |
| 63 | } |
| 64 | next(): IteratorResult<[K, V]> { |
| 65 | if (this.bucketIterator !== undefined) { |
| 66 | return this.bucketIterator.next() |
| 67 | } |
| 68 | const result = this.referentialIterator.next() |
| 69 | if (result.done) { |
| 70 | this.bucketIterator = new BucketIterator(this.self.buckets.values()) |
| 71 | return this.next() |
| 72 | } |
| 73 | return result |
| 74 | } |
| 75 | |
| 76 | [Symbol.iterator](): IterableIterator<[K, V]> { |
| 77 | return new MutableHashMapIterator(this.self) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | class BucketIterator<K, V> implements Iterator<[K, V]> { |
| 82 | constructor(readonly backing: Iterator<NonEmptyArray<readonly [K, V]>>) {} |
nothing calls this directly
no outgoing calls
no test coverage detected