117. Add SortedSet to stdlib/prelude.cp (80/80 cap) and ordered-container API parity (2026-11-21)
- Decision.
- Re-export
std.bag.SortedSetfromstdlib/prelude.cp(prelude count 79 -> 80). The prelude is now full at 80/80, so any later addition must remove an existing prelude name. - Rename
SortedBag.first_where/SortedSet.first_wheretobsearch_first(ok:)and addbsearch_last(ok:), matchingstd.seq.bsearch_first/bsearch_lastlabels and semantics, with boundary monotonicity debug assertions. Removefirst_whereoutright. - Add
set(x, on: Bool)onSet,HashSet, andSortedSet, matchingBitset.set(i, on:). - Add
Set.range(r)andMap.range(r)returningSortedRange<T>/SortedRange<(K, V)>views with O(log n).first/.last/.is_emptyand O(log n + k) forward/reverse iteration. Reject.lenonSet/Maprange views at typecheck time with help pointing toSortedSet/SortedBag(because counting a tree range costs O(log n + k), not O(1)/O(log n)). Enforce ordered-container catalog parity incrates/cpl-cli/tests/builtin_catalog.rs. - Hold
drain(after:/before:, while:)pending the syntax lane's general answer on keyword-labelled parameters for ordinary functions.
- Re-export
- Evidence.
SortedSet: 2 corpus ports (cf2066e.cp,cf2262b.cp) and 3 dreams (dream/cf2062e2.cp,dream/cf2066e.cp,dream/cf2262b.cp) use it; 0 name collisions across the corpus; emitted C++ is byte-identical across measured ports (cf2066e33,421 B,cf2062e228,364 B,cf2262b17,270 B,cf2022c9,560 B) and build time is within noise (-25.6..+2.4 ms). Rewritingcf2262bcollapses 3 parallel structures (Fenwick,Set,Map) into oneSortedSet<I>and passesgate.sh cf2262b 20. - Reverse. Remove
SortedSetfromstdlib/prelude.cp, restorefirst_whereinstdlib/bag.cp, and removeSet/Mapbranches fromsorted_range_call/SortedViewandSet.setlowering.