Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions about implementations of OSSet and OSArray



On Thursday, March 28, 2002, at 12:24 PM, Al Guerra wrote:

1. Why is OSArray a member of OSSet instead of its superclass? Is there some advantage to this in the subset of C++ used?

Both OSArray and OSSet decend from OSCollection (not that OSCollection does much). OSArray allows index based access to members and will grow as needed. OSSet doesn't allow index based access, it is intended to act as an unordered set of unique objects.

With that in mind it doesn't make much sense for it to inherit from OSArray since it doesn't act like one. The fact that it currently uses an OSArray internally as its data store is unrelated (for large sets using an array doesn't make much sense either so keep that in mind when using OSSet).

2. Why aren't NULL values allowed in OSArray?

Not sure... it might be nice to allow for it (think about submitting a bug).

You could define a "NULL" object that could be used for this purpose.

3. Should OSSet::merge() return false if the elements of the added array or set are already elements of set to which they're added?

Not sure how the existing "bool OSSet::merge(const OSSet *set)" method even works... it looks strange to me. Is it just me or does it appear to add the array from the other set and not its members. I think it should be calling merge(set->members) not setObject(set->members).

It does seem a little strange to me as well... as coded it will return true if any but not all members were merged. In the end it does result in a union of the two sets which I think should be the goal. Also It will report the merge failing if the two set are the same which is an incorrect result (I think). It looks like the header doc result comments are a little off (or the implementation is incorrect).

-Shawn
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.

References: 
 >Questions about implementations of OSSet and OSArray (From: "Al Guerra" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.