discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quick question on NSMutableArray


From: Richard Frith-Macdonald
Subject: Re: Quick question on NSMutableArray
Date: Thu, 06 Oct 2005 07:46:18 +0000

On 2005-10-05 22:19:43 +0000 percy tiglao <prtiglao@gmail.com> wrote:

Quick question: Is NSMutableArray a linked list?

No ... though you can easily reimplement it that way in a subclass.

And if it isn't, then what collection class is a linked list?

None of them.

I am trying to implement an input-restricted dequeue, so just
addObject and removeLastObject won't work (basically, need to be able
to be able to remove from both ends of the deque, but I only need 1
side for input)

NSMutable array works for exactly that ...

[queue addObject: anObject]
[queue removeObjectAtIndex: 0];
[queue removeLastobject]

Of course, removing from one end of the queue is relatively inefficient (and increasingly inefficient with queue size) ... though it's not an issue for most applications.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]