3 <title>KOL Help: TTree object (main frame)
</title>
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>
13 TTree = object(
<a href=tobj.htm
target=
"_top">TObj
</a> )
15 Object to store tree-like data in memory (non-visual).
16 <h3 align=
"center"><font color=
"#FF8080">TTree properties
</font></h3>
19 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Name
</b></font>:
<b>String
</b>;
</font>
25 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Data
</b></font>:
<b>Pointer
</b>;
</font>
27 Optional user-defined pointer.
31 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Count
</b></font>:
<b>Integer
</b>;
</font>
32 <font face=
"Webdings" size=
7>Ñ</font>
34 Number of child nodes of given node.
38 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Items
</b></font>[ Idx:
<b>Integer
</b> ]: PTree;
</font>
39 <font face=
"Webdings" size=
7>Ñ</font>
41 Child nodes list items.
45 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Parent
</b></font>: PTree;
</font>
46 <font face=
"Webdings" size=
7>Ñ</font>
48 Returns parent node (or nil, if there is no parent).
52 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Index
</b></font>:
<b>Integer
</b>;
</font>
53 <font face=
"Webdings" size=
7>Ñ</font>
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).
58 <a name=
"prevsibling"></a>
60 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>PrevSibling
</b></font>: PTree;
</font>
61 <font face=
"Webdings" size=
7>Ñ</font>
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>.
67 <a name=
"nextsibling"></a>
69 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>NextSibling
</b></font>: PTree;
</font>
70 <font face=
"Webdings" size=
7>Ñ</font>
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.
77 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Root
</b></font>: PTree;
</font>
78 <font face=
"Webdings" size=
7>Ñ</font>
80 Returns root node (i.e. the last
<a href=#parent
target=
"main">Parent
</a>, enumerating parents recursively).
84 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Level
</b></font>:
<b>Integer
</b>;
</font>
85 <font face=
"Webdings" size=
7>Ñ</font>
87 Returns level of the node, i.e. integer value, equal to
0 for root
88 of a tree,
1 for its children, etc.
92 <font face=
"Courier" color=
"#800080"><b>property
</b> <font color=
"#808000"><b>Total
</b></font>:
<b>Integer
</b>;
</font>
93 <font face=
"Webdings" size=
7>Ñ</font>
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).
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 <font face=
"Webdings" size=
7>N</font>
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 <font face=
"Webdings" size=
7>N</font>
115 <font face=
"Courier" color=
"#800080"><b>procedure
</b> <font color=
"#808000"><b>Clear
</b></font>;
</font>
117 Destoyes all child nodes.
121 <font face=
"Courier" color=
"#800080"><b>procedure
</b> <font color=
"#808000"><b>Add
</b></font>( Node: PTree );
</font>
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>
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>
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.
145 <a name=
"sortbyname"></a>
147 <font face=
"Courier" color=
"#800080"><b>procedure
</b> <font color=
"#808000"><b>SortByName
</b></font>;
</font>
149 Sorts children of the node in ascending order. Sorting is not
150 recursive, i.e. only immediate children are sorted.
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>
156 Swaps two child nodes.
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>
162 Returns true, if Node is the tree itself or is a parent of the given node
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>
169 <a href=#total
target=
"main">Total
</a> index of the child node (on any level under this node).
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>
177 <p align=
"center">[
<a href=index.htm
>Index
</a> ]
</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>