| | |
| | | "use strict"; |
| | | |
| | | /** |
| | | * Nested map structure used to index tuple prefixes until the final tuple |
| | | * element can be stored in a `Set`. |
| | | * @template K |
| | | * @template V |
| | | * @typedef {Map<K, InnerMap<K, V> | Set<V>>} InnerMap |
| | | */ |
| | | |
| | | /** |
| | | * Stores tuples of arbitrary length while preserving efficient prefix lookups |
| | | * through a tree of maps that ends in a set of final values. |
| | | * @template T |
| | | * @template V |
| | | */ |
| | | class TupleSet { |
| | | /** |
| | | * Seeds the tuple set with an optional iterable of tuples. |
| | | * @param {Iterable<[T, V, ...EXPECTED_ANY]>=} init init |
| | | */ |
| | | constructor(init) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Adds a tuple to the set, creating any missing prefix maps along the way. |
| | | * @param {[T, V, ...EXPECTED_ANY]} args tuple |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether the exact tuple is already present in the set. |
| | | * @param {[T, V, ...EXPECTED_ANY]} args tuple |
| | | * @returns {boolean} true, if the tuple is in the Set |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Removes a tuple from the set when it is present. |
| | | * @param {[T, V, ...EXPECTED_ANY]} args tuple |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Iterates over every stored tuple by walking the nested map structure and |
| | | * yielding each complete prefix plus its terminal set value. |
| | | * @returns {Iterator<[T, V, ...EXPECTED_ANY]>} iterator |
| | | */ |
| | | [Symbol.iterator]() { |
| | | /** |
| | | * Iterator type used while traversing nested tuple-prefix maps. |
| | | * @template T, V |
| | | * @typedef {MapIterator<[T, InnerMap<T, V> | Set<V>]>} IteratorStack |
| | | */ |
| | |
| | | let currentSetIterator; |
| | | |
| | | /** |
| | | * Advances through nested maps until a terminal value set is reached or |
| | | * every remaining branch has been exhausted. |
| | | * @param {IteratorStack<T, V>} it iterator |
| | | * @returns {boolean} result |
| | | */ |