initial commit
[rofl0r-KOL.git] / main_ttree.htm
blob7233b4c72619a66eb76071da8adae025639c8a97
1 <html>
2 <head>
3 <title>KOL Help: TTree object (main frame)</title>
4 <base target="_top">
5 </head>
7 <body bgcolor="#FFFFEF" text="#000000" link="#008080" vlink="#008000" alink="#808000">
8 <p><font face="Courier" color="#800080"><b>TTree( unit <a href=kol_pas.htm>KOL.pas</a> )
9 <font face="Wingdings">ï</font> <a href=tobj.htm>TObj</a>
10 <font face="Wingdings">ï</font> <a href=_tobj.htm>_TObj</a>
11 </b></font></p>
12 <p><b>
13 TTree = object( <a href=tobj.htm target="_top">TObj</a> )
14 </b></p>
15 Object to store tree-like data in memory (non-visual).
16 <h3 align="center"><font color="#FF8080">TTree properties</font></h3>
17 <a name="name"></a>
18 <p>
19 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Name</b></font>: <b>String</b>;</font>
20 <br>
21 Optional node name.
22 </p>
23 <a name="data"></a>
24 <p>
25 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Data</b></font>: <b>Pointer</b>;</font>
26 <br>
27 Optional user-defined pointer.
28 </p>
29 <a name="count"></a>
30 <p>
31 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Count</b></font>: <b>Integer</b>;</font>
32 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
33 <br>
34 Number of child nodes of given node.
35 </p>
36 <a name="items"></a>
37 <p>
38 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Items</b></font>[ Idx: <b>Integer</b> ]: PTree;</font>
39 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
40 <br>
41 Child nodes list items.
42 </p>
43 <a name="parent"></a>
44 <p>
45 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Parent</b></font>: PTree;</font>
46 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
47 <br>
48 Returns parent node (or nil, if there is no parent).
49 </p>
50 <a name="index"></a>
51 <p>
52 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Index</b></font>: <b>Integer</b>;</font>
53 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
54 <br>
55 Returns an index of the node in a list of nodes of the same parent
56 (or -1, if <a href=#parent target="main">Parent</a> is not defined).
57 </p>
58 <a name="prevsibling"></a>
59 <p>
60 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>PrevSibling</b></font>: PTree;</font>
61 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
62 <br>
63 Returns previous node in a list of children of the <a href=#parent target="main">Parent</a>. Nil is
64 returned, if given node is the first child of the <a href=#parent target="main">Parent</a> or has
65 no <a href=#parent target="main">Parent</a>.
66 </p>
67 <a name="nextsibling"></a>
68 <p>
69 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>NextSibling</b></font>: PTree;</font>
70 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
71 <br>
72 Returns next node in a list of children of the <a href=#parent target="main">Parent</a>. Nil is returned,
73 if given node is the last child of the <a href=#parent target="main">Parent</a> or has no <a href=#parent target="main">Parent</a> at all.
74 </p>
75 <a name="root"></a>
76 <p>
77 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Root</b></font>: PTree;</font>
78 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
79 <br>
80 Returns root node (i.e. the last <a href=#parent target="main">Parent</a>, enumerating parents recursively).
81 </p>
82 <a name="level"></a>
83 <p>
84 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Level</b></font>: <b>Integer</b>;</font>
85 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
86 <br>
87 Returns level of the node, i.e. integer value, equal to 0 for root
88 of a tree, 1 for its children, etc.
89 </p>
90 <a name="total"></a>
91 <p>
92 <font face="Courier" color="#800080"><b>property</b> <font color="#808000"><b>Total</b></font>: <b>Integer</b>;</font>
93 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#209;</font>&nbsp;&nbsp;&nbsp;
94 <br>
95 Returns total number of children of the node and all its children
96 counting its recursively (but node itself is not considered, i.e.
97 Total for node without children is equal to 0).
98 </p>
99 <h4 align="center"><font color="black">Properties, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
100 <h3 align="center"><font color="#FF8080">TTree methods</font></h3>
101 <a name="createtree"></a>
103 <font face="Courier" color="#800080"><b>constructor</b> <font color="#808000"><b>CreateTree</b></font>( AParent: PTree; <b>const</b> AName: <b>String</b> );</font>
104 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#78;</font>&nbsp;&nbsp;&nbsp;
105 <br>
106 </p>
107 <a name="destroy"></a>
109 <font face="Courier" color="#800080"><b>destructor</b> <font color="#808000"><b>Destroy</b></font>; <b>virtual</b>;</font>
110 &nbsp;&nbsp;&nbsp;<font face="Webdings" size=7>&#78;</font>&nbsp;&nbsp;&nbsp;
111 <br>
112 </p>
113 <a name="clear"></a>
115 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Clear</b></font>;</font>
116 <br>
117 Destoyes all child nodes.
118 </p>
119 <a name="add"></a>
121 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Add</b></font>( Node: PTree );</font>
122 <br>
123 Adds another node as a child of given tree node. This operation
124 as well as <a href=#insert target="main">Insert</a> can be used to move node together with its children
125 to another location of the same tree or even from another tree.
126 Anyway, added Node first correctly removed from old place (if it is
127 defined for it). But for simplest task, such as filling of tree with
128 nodes, code should looking as follows:
129 <p align=left><font face="Courier" color="008080"><b><pre>
130 Node := <a href="kol_pas.htm#newtree target="_top""><font color="008080">NewTree</font></a>( nil, <font color="A08020">'test of creating node without parent'</font> );
131 RootOfMyTree.Add( Node );
132 </pre></b></font></p>
133 Though, this code gives the same result as:
134 <p align=left><font face="Courier" color="008080"><b><pre>
135 Node := <a href="kol_pas.htm#newtree target="_top""><font color="008080">NewTree</font></a>( RootOfMyTree, <font color="A08020">'test of creatign node as a child'</font> );
136 </pre></b></font></p>
137 </p>
138 <a name="insert"></a>
140 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>Insert</b></font>( Before, Node: PTree );</font>
141 <br>
142 Inserts earlier created 'Node' just before given child node 'Before'
143 as a child of given tree node. See also <a href=#add target="main">Add</a> method.
144 </p>
145 <a name="sortbyname"></a>
147 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>SortByName</b></font>;</font>
148 <br>
149 Sorts children of the node in ascending order. Sorting is not
150 recursive, i.e. only immediate children are sorted.
151 </p>
152 <a name="swapnodes"></a>
154 <font face="Courier" color="#800080"><b>procedure</b> <font color="#808000"><b>SwapNodes</b></font>( i1, i2: <b>Integer</b> );</font>
155 <br>
156 Swaps two child nodes.
157 </p>
158 <a name="isparentofnode"></a>
160 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>IsParentOfNode</b></font>( Node: PTree ): <b>Boolean</b>;</font>
161 <br>
162 Returns true, if Node is the tree itself or is a parent of the given node
163 on any level.
164 </p>
165 <a name="indexof"></a>
167 <font face="Courier" color="#800080"><b>function</b> <font color="#808000"><b>IndexOf</b></font>( Node: PTree ): <b>Integer</b>;</font>
168 <br>
169 <a href=#total target="main">Total</a> index of the child node (on any level under this node).
170 </p>
171 <h4 align="center"><font color="black">Methods, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
172 <h3 align="center"><font color="#FF8080">TTree events</font></h3>
173 <h4 align="center"><font color="black">Events, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
174 <h3 align="center"><font color="#FF8080">TTree fields</font></h3>
175 <h4 align="center"><font color="black">Fields, inherited from <a href="tobj.htm" target="_top">TObj</a></font></h4>
176 <hr>
177 <p align="center">[&nbsp;<a href=index.htm>Index</a>&nbsp;]</p>
178 <p align="center"><font face="Comic Sans MS"><small>This help is generated 22-Sep-2005 by KOL Help generator, (C) 2000-2001 by Vladimir Kladov<br>Modified (C) 2003 by Alexander Bartov</small></font></p>
179 </body>
180 </html>