Re: WTF? How can this work?
Re: WTF? How can this work?
- Subject: Re: WTF? How can this work?
- From: Greg Titus <email@hidden>
- Date: Mon, 20 Aug 2001 10:40:40 -0700
On Monday, August 20, 2001, at 02:49 AM, John C. Randolph wrote:
On Sunday, August 19, 2001, at 06:34 PM, Chris Kane wrote:
Mutable collections tend to have "extra slots" allocated to avoid
reallocation on every addition, which kills performance.
I don't suppose you have by any chance, any plans for a fragmentable
array for those occasions where you might have a *lot* of objects in
the array? Or, say, NSReallyBigAndNotNecessarilyContiguousData, for
the future when we have a 64-bit address space?
While I'm on the wish list, it might be nice to have an NSQueue or
NSFIFOArray.
Hi John,
Check out the CoreFoundation source code some time. There are several
implementations of mutable CFArrays: for small arrays the implementation
is a ring buffer (which is efficient for queues), and for very large
arrays the implementation is to use a CFStorage, which looks sort of
like an in-memory b-tree. I'm not sure what you mean by "fragmentable",
but this probably qualifies.
Since NSMutableArray uses CoreFoundation, you've already got what you
are looking for, more or less. It's true that the array isn't
thread-safe, so you do need a couple more lines of code to write a
thread-safe FIFO.
--Greg