* This method returns an iterator over all values for a given key. * @param key - The key to get the values for. * @returns An iterator of value tuples [value, multiplicity].
(key: TKey)
| 244 | * @returns An iterator of value tuples [value, multiplicity]. |
| 245 | */ |
| 246 | *getIterator(key: TKey): Iterable<[TValue, number]> { |
| 247 | const mapOrSingleValue = this.#inner.get(key) |
| 248 | if (isSingleValue(mapOrSingleValue)) { |
| 249 | yield mapOrSingleValue |
| 250 | } else if (mapOrSingleValue === undefined) { |
| 251 | return |
| 252 | } else if (mapOrSingleValue instanceof ValueMap) { |
| 253 | // Direct ValueMap - all values have NO_PREFIX |
| 254 | for (const valueTuple of mapOrSingleValue.values()) { |
| 255 | yield valueTuple |
| 256 | } |
| 257 | } else { |
| 258 | // PrefixMap - iterate through all prefixes |
| 259 | for (const singleValueOrValueMap of mapOrSingleValue.values()) { |
| 260 | if (isSingleValue(singleValueOrValueMap)) { |
| 261 | yield singleValueOrValueMap |
| 262 | } else { |
| 263 | for (const valueTuple of singleValueOrValueMap.values()) { |
| 264 | yield valueTuple |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | /** |
| 272 | * This returns an iterator that iterates over all key-value pairs. |
no test coverage detected