Removed bound-query method on SortedBag or SortedSet
first_ge/first_gt/last_le/last_lt/count_range on SortedBag/SortedSet: use .range(r)
var s = SortedBag<Int>()
print(s.first_ge(3) ?? -1, s.last_lt(5) ?? -1, s.count_range(1, 5))var s = SortedBag<Int>()
print(s.range(3..).first ?? -1, s.range(..5).last ?? -1, s.range(1..5).len)Why
SortedBag.range(r) and SortedSet.range(r) return an view whose .first, .last, and .len cost and whose iteration costs . cpl fix rewrites first_ge/first_gt/last_le/last_lt/count_range to .range(...) calls.
The practice it serves
A hand-written pattern the language or the standard library already says in one step. Family: S.seq: ordering and ranks.
Not flagged
A near miss: close to the pattern, but not it.
var s = SortedBag<Int>()
s.add(3)
print(s.len)Turn it off
For one block, wrap it in with lint(sorted_range_method: allow):. For a project, add sorted_range_method = "allow" under [lints] in cp.toml.
Generated from spec/lints/sorted_range_method, the same record the linter is built from.