on Tue Oct 18 2016, Max Moiseev <swift-evolution@swift.org> wrote:

> Hi Louis,
>
> I believe the difference is due to the performance guarantees. One can
> only efficiently implement `popFirst` and `removeFirst` on slices,
> where it’s just a matter of index manipulation. 

Well, and on deques, doubly-linked lists, and circular buffers.

> Removing the first element of a Collection is potentially an O(n)
> operation. Using `popFirst` in a loop in some algorithm would result
> in a quadratic complexity.
>
> So the reason is: we only provide `popFirst` in a context where it is
> guaranteed to be O(1). Same applies to `popLast`, actually.. I think.

Right.

--
Dave

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to