[swift-evolution] [Proposal]: Drastically improve searching API (indexOf(…)) of CollectionType
Vincent Esche
regexident.mailinglists at gmail.com
Mon Jan 4 18:24:09 CST 2016
That was my reasoning behind choosing Indexable and not CollectionType.
Neither the Swift documents, nor the “headers” indicate any semi-privateness of Indexable, AFAIK.
(Apart from maybe Base._Element kind of hinting at it, but then again it’s Indexable, not _Indexable.)
Anyway, I’d be totally fine with sticking it on CollectionType, if that’s preferred.
Vincent
> On 05 Jan 2016, at 00:58, T.J. Usiyan via swift-evolution <swift-evolution at swift.org> wrote:
>
> The proposed additions to Indexible only require Indices… I don't see how adding them is such a mistake. If we can gain these behaviors while only *requiring* that minimum interface… go for it.
>
> TJ
>
> On Mon, Jan 4, 2016 at 3:49 PM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> I'm not sure about the rest of this, but...
>
> >> 1. A backwards-compatible refactoring of `CollectionType.indices`, moving it to `Indexable`.
> >>
> >> 2. A backwards-compatible refactoring of `indexOf(…)` (adding optional `range:` and moving it to `Indexable`).
> >>
> >> 3. The addition of `rangeOf(…)`, `countOf(…)` and `isSorted(…)` to `Indexable` with a TIME complexity of `O(self.count)`.
> >>
> >> 4. The introduction of a `BinarySearchView` on `Indexable`, allowing for fast (`O(log2(self.count))`) searches on `Indexable` via `indexOf(…)`, `rangeOf(…)`, `countOf(…)`, `lowerBoundOf(…)`, `upperBoundOf(…)` without cluttering `Indexable`'s interface.
>
> I don't think you quite understand what `Indexable` is for.
>
> `Indexable` is a minimal protocol containing the very most basic parts of `CollectionType`'s interface. It's used to avoid circular definitions in `CollectionType`. The doc comments on it describe it as "almost an implementation detail". I don't think it's appropriate to move a whole bunch of stuff into `Indexable` when it's supposed to be a minimal protocol.
>
> --
> Brent Royal-Gordon
> Architechies
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160105/24024a50/attachment.html>
More information about the swift-evolution
mailing list