* Performs a reversed range query
(options: RangeQueryOptions = {})
| 313 | * Performs a reversed range query |
| 314 | */ |
| 315 | rangeQueryReversed(options: RangeQueryOptions = {}): Set<TKey> { |
| 316 | const { from, to, fromInclusive = true, toInclusive = true } = options |
| 317 | |
| 318 | // Swap from/to and fromInclusive/toInclusive to handle reversed ranges |
| 319 | // If to is undefined, we want to start from the end (max value) |
| 320 | // If from is undefined, we want to end at the beginning (min value) |
| 321 | const swappedFrom = |
| 322 | to ?? |
| 323 | (this.sortedValues.length > 0 |
| 324 | ? this.sortedValues[this.sortedValues.length - 1] |
| 325 | : undefined) |
| 326 | const swappedTo = |
| 327 | from ?? (this.sortedValues.length > 0 ? this.sortedValues[0] : undefined) |
| 328 | |
| 329 | return this.rangeQuery({ |
| 330 | from: swappedFrom, |
| 331 | to: swappedTo, |
| 332 | fromInclusive: toInclusive, |
| 333 | toInclusive: fromInclusive, |
| 334 | }) |
| 335 | } |
| 336 | |
| 337 | /** |
| 338 | * Returns the next n items in sorted order |
nothing calls this directly
no test coverage detected