Open jba opened 1 day ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Is there any difference between this Merge and the one in #61898?
If this package gets added, it seems like a good place for the sequence equivalent for Compact: #67441
I propose adding a package of functions that operate on iterators whose values are sorted.
Sorted sequences can arise in a number of ways:
Common operations on pairs of sorted sequences include merging them into a single sorted sequence, as well as the set operations union, intersection and set difference. I propose a package with these operations, with the API given below.
As is common in packages like
slices
, there are two functions for each operation, one using the natural ordering of a type and one that accepts a comparison function. We could also consider adding functions that operate on the keys ofiter.Seq2
s, bringing along the corresponding values. I don't know if those sequences would arise enough to make that worthwhile. We could reconsider adding theSeq2
functions if and when we add ordered maps.API
There is a working implementation at github.com/jba/sorted.