[swift-evolution] Collection index complexity and data structures
swift-evolution at haravikk.me
Fri Jun 24 16:52:38 CDT 2016
I started a discussion thread that may be of interest to you, basically discussing the possibility for directional methods to reduce confusion/clarify intent, should be accessible at the following URL:
> On 24 Jun 2016, at 22:05, David Waite via swift-evolution <swift-evolution at swift.org> wrote:
> And never mind me. Not sure how I missed that in the docs that many times.
>> On Jun 24, 2016, at 1:38 PM, David Waite via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> I noticed that the new Collection index(_:offsetBy:) <http://swiftdoc.org/v3.0/protocol/Collection/#comment-func-index_offsetby_> does not define that negative offsets require a BidirectionalCollection. It also declares that negative offsets must complete in O( | offset | ) time. This differs from other methods such as distance(from:to:) <http://swiftdoc.org/v3.0/protocol/Collection/#comment-func-distance-from_to_>which indicates start <= end if not a BidirectionalCollection
>> This would preclude some data structures from strictly implementing the Collection protocol, such as singly-linked lists.
>> Would it be appropriate to indicate instead that BidirectionalCollection defines the negative offset behavior and negative offset performance constraint?
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution