[swift-evolution] removeFirst, optional equiviliant

Dave Abrahams dabrahams at apple.com
Wed Jan 6 17:47:19 CST 2016


> 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.

> 
> Jacob
> 
> On Wed, Jan 6, 2016 at 3:41 PM, Dave Abrahams via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> That method exists and is called popFirst
> 
> However, if you have an Array I suggest using popLast instead if you have the choice :-)
> 
>> On Jan 6, 2016, at 9:36 AM, James Campbell via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> If you call removeFirst and the array is empty it would be great if it was optional so it could return nil or at least it threw an error so you could handle that case.
>> 
>> -- 
>>  Wizard
>> james at supmenow.com <mailto:james at supmenow.com>
>> +44 7523 279 698 <tel:%2B44%207523%20279%20698> _______________________________________________
>> 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>
> 
> -Dave
> 
> 
> 
> 
> 
> _______________________________________________
> 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>
> 
> 

-Dave



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160106/0b9da826/attachment.html>


More information about the swift-evolution mailing list