[swift-evolution] [Review] SE-0074: Implementation of Binary Search functions

Dave Abrahams dabrahams at apple.com
Fri May 13 09:36:08 CDT 2016


on Mon May 09 2016, Nate Cook <natecook-AT-gmail.com> wrote:

> Yet another alternative would be to drop Set and Dictionary down a
> level to a FiniteSequence protocol in between Sequence and
> Collection. Basically none of the index-based collection APIs
> (i.e. everything except `count` and `isEmpty`) make sense on sets and
> dictionaries. 

Strongly disagreed.  Any read-only operation that makes sense on a
bidirectional collection makes sense on these data structures.

> index(where:) was marginally useful with dictionaries, but now that
> Sequence is getting first(where:), née find(...), even that isn't
> necessary.

   s.remove(at: s.index(where: { $0 < 1 }))

-- 
-Dave


More information about the swift-evolution mailing list