103. SortedSet.range(r) and SortedBag.range(r) replace the 5 bound-query methods (2026-11-21)
- Decision:
SortedBag<K>.range(r)andSortedSet<K>.range(r)(std.bag.SortedSet, supersedingOrderedSet) return an O(1)SortedRange<K>view over any ordered range (a..b,a..=b,..b,..=b,a..,.., orRange<D>)..first,.last,.len, and.is_emptyrun in O(log n) expected time; iteration (for x in s.range(r),.rev, comprehensions, and folds like.sum()) runs in O(log n + k) expected time with zero view allocation.first_ge,first_gt,last_le,last_lt, andcount_rangeare removed fromSortedBag/SortedSetwith checker diagnostics and lintL0515(cpl fixcodemod) rewriting all 5 methods to.range(...). - Reason: Closes the
cf2062e2dream friction where querying keys outside a subtree (heavier.range(..r.lo),heavier.range(r.hi..),heavier.range(r)) needed five separate bound methods with hand-picked comparisons. LoweringSortedRange<K>to captured range bounds over the receiver place keeps view construction O(1) and matches hand-written C++ treaps (1.12xinbench/containers/sorted_range). - Reverse: Re-add
first_ge/first_gt/last_le/last_lt/count_rangeonSortedBag/SortedSetinstdlib/bag.cp, removeSortedRangehandling fromcpl-check/cpl-ir, and dropL0515fromcpl-lint.