forked from mykeepass/KeePassLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tree.m
49 lines (38 loc) · 782 Bytes
/
Tree.m
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
//
// Tree.m
// KeePass2
//
// Created by Qiang Yu on 2/11/10.
// Copyright 2010 Qiang Yu. All rights reserved.
//
#import "Tree.h"
@interface Tree(PrivateMethods)
-(void)printTree:(Node *)node Indent:(int)indent;
@end
@implementation Tree
@synthesize _root;
-(void)dealloc{
[_root breakCyclcReference];
[_root release];
[super dealloc];
}
-(void)print{
if(_root){
[self printTree:_root Indent:0];
}
}
-(void)printTree:(Node *)node Indent:(int)indent{
#ifdef DEBUG
NSMutableString * format = [[NSMutableString alloc]init];
for (int i=0; i<indent; i++){
[format appendString:@"\t"];
}
[format appendString:@"%@"];
NSLog(format, node);
[format release];
for(Node * child in node._children){
[self printTree:child Indent:indent+1];
}
#endif
}
@end