This adds the two variations of the equalRange method and fixes a few issues with the existing code. The methods are now marked public, so you can drop this in a Playground's Sources directory and test the methods there.
The extension constraints for the equalRange method are ugly because it calls the other methods on its subsequences—those extra bits are essentially the definition of a subsequence, but the compiler can't require them without all that extra stuff.
I don't particularly like the equalRange name—I know it's what C++ calls that algorithm but it doesn't describe it very well. What do you all think of range(of:) or bounds(of:) to match lower/upperBound?
This adds the two variations of the
equalRange
method and fixes a few issues with the existing code. The methods are now markedpublic
, so you can drop this in a Playground's Sources directory and test the methods there.The extension constraints for the
equalRange
method are ugly because it calls the other methods on its subsequences—those extra bits are essentially the definition of a subsequence, but the compiler can't require them without all that extra stuff.I don't particularly like the
equalRange
name—I know it's what C++ calls that algorithm but it doesn't describe it very well. What do you all think ofrange(of:)
orbounds(of:)
to matchlower/upperBound
?