-
Notifications
You must be signed in to change notification settings - Fork 305
/
TreeNode.h
66 lines (53 loc) · 1.66 KB
/
TreeNode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 3.0 Edition
BSD License, Use at your own risk
*/
//
// TreeNode.h
// Created by Erica Sadun on 4/6/09. Updated 4/26
//
#import <CoreFoundation/CoreFoundation.h>
@interface TreeNode : NSObject
{
TreeNode *parent;
NSMutableArray *children;
NSString *key;
NSString *leafvalue;
}
@property (nonatomic, retain) TreeNode *parent;
@property (nonatomic, retain) NSMutableArray *children;
@property (nonatomic, retain) NSString *key;
@property (nonatomic, retain) NSString *leafvalue;
@property (nonatomic, readonly) BOOL isLeaf;
@property (nonatomic, readonly) BOOL hasLeafValue;
@property (nonatomic, readonly) NSArray *keys;
@property (nonatomic, readonly) NSArray *allKeys;
@property (nonatomic, readonly) NSArray *uniqKeys;
@property (nonatomic, readonly) NSArray *uniqAllKeys;
@property (nonatomic, readonly) NSArray *leaves;
@property (nonatomic, readonly) NSArray *allLeaves;
@property (nonatomic, readonly) NSString *dump;
+ (TreeNode *) treeNode;
- (NSString *) dump;
- (void) teardown;
// Leaf Utils
- (BOOL) isLeaf;
- (BOOL) hasLeafValue;
- (NSArray *) leaves;
- (NSArray *) allLeaves;
// Key Utils
- (NSArray *) keys;
- (NSArray *) allKeys;
- (NSArray *) uniqKeys;
- (NSArray *) uniqAllKeys;
// Search Utils
- (TreeNode *) objectForKey: (NSString *) aKey;
- (NSString *) leafForKey: (NSString *) aKey;
- (NSMutableArray *) objectsForKey: (NSString *) aKey;
- (NSMutableArray *) leavesForKey: (NSString *) aKey;
- (TreeNode *) objectForKeys: (NSArray *) keys;
- (NSString *) leafForKeys: (NSArray *) keys;
// Convert Utils
- (NSMutableDictionary *) dictionaryForChildren;
@end