Implementing a Collection.removingIndices(_:)

Something has always bugged me about this solution, even as I was writing that post. A predicate means that the code has to test against every valid index before determining what to delete. The other versions of the method given around here use an explicit list of the elements they want gone, so the indexes of uninvolved elements are never tested. Those other methods can add a Hashable requirement to Index, or allow the targeted indexes to be listed in any order and/or have repeats, or all of the above.

We need a Sequence that can guarantee that it contains its element values exactly once, in increasing order, and exploit the already-required Comparable conformance instead of unnecessarily adding a Hashable one. I dusted off a desire to copy C++'s comparable-based associative containers and wrote a sorted-set type. The new requirement method to RangeReplacableCollection will take a SortedSet<Index> as its parameter, which any other sequence of indexes can convert to, and use the set to arrange how it will remove multiple discontinuous elements without losing track after the first block is removed.