WXL
3 天以前 9bce51f651aad297ef9eb6df832bfdaf1de05d84
node_modules/webpack/lib/util/TupleSet.js
@@ -6,17 +6,22 @@
"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) {
@@ -31,6 +36,7 @@
   }
   /**
    * Adds a tuple to the set, creating any missing prefix maps along the way.
    * @param {[T, V, ...EXPECTED_ANY]} args tuple
    * @returns {void}
    */
@@ -59,6 +65,7 @@
   }
   /**
    * 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
    */
@@ -83,6 +90,7 @@
   }
   /**
    * Removes a tuple from the set when it is present.
    * @param {[T, V, ...EXPECTED_ANY]} args tuple
    * @returns {void}
    */
@@ -109,10 +117,13 @@
   }
   /**
    * 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
       */
@@ -127,6 +138,8 @@
      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
       */