Re: Collection classes
Re: Collection classes
- Subject: Re: Collection classes
- From: Chris Ridd <email@hidden>
- Date: Thu, 08 Jan 2004 14:51:57 +0000
On 8/1/04 2:08 pm, Timothy Reaves <email@hidden> wrote:
>
What's not to like? Are you kidding? :-)
>
>
New classes might not be needed, but some new functionality is. Whereas
>
I'm still learning Objective-C, I'm not sure what I want can be done with
>
an interface, although if it could, that'd be fine.
>
>
What is missing is the ability to order collections.
>
>
NSArray is an ordered, unbounded collection. So that can be used as a
>
list. That's fine. But having NSArray be the only ordered collection is
>
a bit limiting.
>
>
I need a set. A set excludes duplicates, and is not ordered. It is not by
>
definition unordered, it is just that order is not imposed. That is a
>
fine distinction, but a distenction none-the-less. Now, for what I am
>
currently working on, I also need order. I can find no ordered collection
>
with set symantics in the Cocoa class library.
>
>
I am implementing a table data source. I have a class (Foo) that has an
>
instance attribute (bar) of type NSMutableSet that I want to have the
>
table display. The contract of bar is that it not allow duplicates, so it
>
HAS to be a NSSet*, as that is the only collection that enforces that
>
contract. The Cocoa data sources in Cocoa want collections that are
>
indexable, and I understand why.
>
>
But how should I then model my non-indexable collection in an indexable
>
way? So far I have not found an easy way to do this in Cocoa. Converting
What about using an NSDictionary, with the keys being the things you want in
your collection. I'm not sure if you can use nil as the object for each key,
or whether you'd need to use the shared instance of NSNull instead.
Dictionaries require unique keys and return the keys in "some" order, which
would seem to satisfy your requirement..
Cheers,
Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.