Re: A tree data structure?
Re: A tree data structure?
- Subject: Re: A tree data structure?
- From: Andreas Grosam <email@hidden>
- Date: Tue, 5 May 2009 18:10:03 +0200
On May 5, 2009, at 4:46 PM, BJ Homer wrote:
You may be interested the CHDataStructures framework, hosted by the
BYU CocoaHeads group. It has a number of such structures that
should work for you.
http://cocoaheads.byu.edu/code/CHDataStructures
-BJ Homer
This is a quite interesting framework, however the "trees" are *search
structures*. This has the subtle difference, that the data elements
have to be sortable (respond to -compare message) and must be unique.
The primary purpose for such kind of trees is to provide a container
for storing and fast retrieval of objects. The data structure is an
implementation detail.
What I'm looking for is a data container for implementing a
hierarchical data structure. The difference is, that data needs to be
inserted at arbitrary positions and levels. That means, the "data
structure" is my data, not merely a means to store and search for
objects - and is not an implementation detail (but far more simple to
implement).
Nonetheless, the framework looks very appealing, and I 'm sure I can
use it somewhere else. ;)
Regards
Andreas
On Tue, May 5, 2009 at 7:10 AM, Andreas Grosam
<email@hidden> wrote:
NSTreeController and CFTree is not exactly what I'm searching for. I
would like to have a *pure*, simple and effective but complete tree
data structure which comprises a hierarchy of objects:
root
|- object1
|- object2
|- object4
|- object5
The container shall be sequential, that is its elements shall be
ordered.
A possible approach could look like this:
@interface Tree {
Node* root;
}
-(void) addObject: (NSObject)* data into:(Node*)parent;
-(TreeEnumerator*) enumeratorOfType:(int) enumeratorType;
- (int) count;
...
@end
Class Node contains the data and structural information:
@interface Node {
NSMutableArray* data;
Node* parent;
}
-(void) addObject:(NSObject*) data;
-(int) count;
...
@end
Is there already something available like this?
Thanks in advance for hints.
Regards
Andreas Grosam
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden