[swift-evolution] removeFirst, optional equiviliant

James Campbell james at supmenow.com
Wed Jan 6 18:30:57 CST 2016


Yeah I was using this for a LIFO type system :) glad to know there is a
method for this.

On Thu, Jan 7, 2016 at 12:09 AM, Dave Abrahams <dabrahams at apple.com> wrote:

>
> On Jan 6, 2016, at 3:48 PM, Jacob Bandes-Storch <jtbandes at gmail.com>
> wrote:
>
> Whoops, I meant append()/popFirst. That is, even for a single-ended queue,
> you'll use one "first" operation (less efficient) and one "last" operation.
>
>
> No, a single-ended queue is a stack.  You can use append and popLast on
> Array for that.
>
>
> On Wed, Jan 6, 2016 at 3:47 PM, Dave Abrahams <dabrahams at apple.com> wrote:
>
>>
>> On Jan 6, 2016, at 3:42 PM, Jacob Bandes-Storch <jtbandes at gmail.com>
>> wrote:
>>
>> Oops, I forgot this existed.
>>
>> I'm assuming you're recommending popLast for performance reasons?
>> Unfortunately, for a
>>
>>
>> …double-ended…
>>
>> queue, you'll need either insertAtIndex(0)/popLast or append()/popLast
>> (or a different data structure)…
>>
>>
>> Yes, the standard library should acquire a Deque data structure at some
>> point.
>>
>
> Is there a SR for this?
>
>
> Not that I know of; have at it!
>
> -Dave
>
>
>
>


-- 
 Wizard
james at supmenow.com
+44 7523 279 698
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160107/eae84b87/attachment.html>


More information about the swift-evolution mailing list