Debian Codegraph @

html/Blt_Tree.html

raw symbols SCIP
1
2 <!-- manual page source format generated by PolyglotMan v3.0.9, -->
3 <!-- available via anonymous ftp from ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z -->
4
5 <HTML>
6 <HEAD>
7 <TITLE>Blt_Tree(3) manual page</TITLE>
8 </HEAD>
9 <BODY bgcolor=white>
10 <A HREF="#toc">Table of Contents</A><P>
11
12 <H2><A NAME="sect0" HREF="#toc0">Name</A></H2>
13 Blt_Tree - Tree data object.
14 <H2><A NAME="sect1" HREF="#toc1">Synopsis</A></H2>
15 <BR>
16 <PRE>#include &lt;bltTree.h&gt;
17
18 struct Blt_Tree {
19 Tcl_Alloc(size)
20
21 Tcl_Free(ptr)
22
23 char *
24 Tcl_Realloc(ptr, size)
25 </PRE>
26 <H2><A NAME="sect2" HREF="#toc2">Arguments</A></H2>
27 <P>
28 int <I>size</I><tt> </tt>&nbsp;<tt> </tt>&nbsp;(in)<BR>
29 <tt> </tt>&nbsp;<tt> </tt>&nbsp;Size in bytes of the memory block to allocate. <P>
30 char <I>*ptr</I><tt> </tt>&nbsp;<tt> </tt>&nbsp;(in)<BR>
31 <tt> </tt>&nbsp;<tt> </tt>&nbsp;Pointer to memory block to free or realloc. <P>
32
33 <H2><A NAME="sect3" HREF="#toc3">Description</A></H2>
34 <P>
35 These procedures
36 provide a platform and compiler independent interface for memory allocation.
37 Programs that need to transfer ownership of memory blocks between Tcl
38 and other modules should use these routines rather than the native <B>malloc()</B>
39 and <B>free()</B> routines provided by the C run-time library. <P>
40 <B>Tcl_Alloc</B> returns
41 a pointer to a block of at least <I>size</I> bytes suitably aligned for any use.
42 <P>
43 <B>Tcl_Free</B> makes the space referred to by <I>ptr</I> available for further allocation.
44 <P>
45 <B>Tcl_Realloc</B> changes the size of the block pointed to by <I>ptr</I> to <I>size</I> bytes
46 and returns a pointer to the new block. The contents will be unchanged up
47 to the lesser of the new and old sizes. The returned location may be different
48 from <I>ptr</I>.
49 <H2><A NAME="sect4" HREF="#toc4">Tree Object Routines</A></H2>
50 The following library routines allow you to
51 create and destroy tree objects. Each tree object has a name that uniquely
52 identifies it. Tree objects can also be shared. For example, the <B>tree</B> and
53 <B>hiertable</B> commands may access the same tree data object. Each client grabs
54 a token associated with the tree. When all tokens are released the tree
55 data object is automatically destroyed.
56 <DL>
57
58 <DT><B>Blt_TreeCreate</B> </DT>
59 <DD>Create a tree data
60 object and optionally obtains a token associated with it. </DD>
61
62 <DT><B>Blt_TreeExists</B>
63 </DT>
64 <DD>Indicates if a tree by a given name exists. </DD>
65
66 <DT><B>Blt_TreeGetToken</B> </DT>
67 <DD>Obtains a token
68 for an existing tree data object. </DD>
69
70 <DT><B>Blt_TreeReleaseToken</B> </DT>
71 <DD>Releases a token
72 for a tree data object. The tree object is deleted when all outstanding
73 tokens have been released. </DD>
74
75 <DT><B>Blt_TreeName</B> </DT>
76 <DD>Returns the name of the tree object.
77 </DD>
78
79 <DT><B>Blt_TreeChangeRoot</B> </DT>
80 <DD>Specifies a node as the new root to a tree. </DD>
81 </DL>
82
83 <H2><A NAME="sect5" HREF="#toc5">Treenode
84 Routines</A></H2>
85 Tree objects initially contain only a root node. You can add or
86 delete nodes with the following routines.
87 <DL>
88
89 <DT><B>Blt_TreeCreateNode</B> </DT>
90 <DD>Creates a new
91 child node for a given parent in the tree. </DD>
92
93 <DT><B>Blt_TreeDeleteNode</B> </DT>
94 <DD>Deletes
95 a node and its children. </DD>
96
97 <DT><B>Blt_TreeNodeId</B> </DT>
98 <DD>Returns the unique node identifier
99 for a node. </DD>
100
101 <DT><B>Blt_TreeGetNode</B> </DT>
102 <DD>Gets a node based upon its identifier. </DD>
103
104 <DT><B>Blt_TreeFindChild</B>
105 </DT>
106 <DD>Searches for a child node given by its label in a parent node. </DD>
107
108 <DT><B>Blt_TreeNodeLabel</B>
109 </DT>
110 <DD>Returns the current label for a node. </DD>
111
112 <DT><B>Blt_TreeRelabelNode</B> </DT>
113 <DD>Resets a node's
114 label. </DD>
115
116 <DT><B>Blt_TreeNodePath</B> </DT>
117 <DD>Returns the fullpath to a node. </DD>
118
119 <DT><B>Blt_TreeNodeDepth</B>
120 </DT>
121 <DD>Returns the depth of the node. </DD>
122
123 <DT><B>Blt_TreeNodeDegree</B> </DT>
124 <DD>Returns the number of
125 children for a node. </DD>
126
127 <DT><B>Blt_TreeIsLeaf</B> </DT>
128 <DD>Indicates if a node has no children.
129 </DD>
130
131 <DT><B>Blt_TreeIsBefore</B> </DT>
132 <DD>Indicates if a node is before another node in depth-first
133 search order. </DD>
134
135 <DT><B>Blt_TreeIsAncestor</B> </DT>
136 <DD>Indicates if a node is an ancestor or another.
137 </DD>
138
139 <DT><B>Blt_TreeSortNode</B> </DT>
140 <DD>Sorts the children of a node. </DD>
141
142 <DT><B>Blt_TreeSize</B> </DT>
143 <DD>Returns the
144 number of nodes in a node and its descendants. </DD>
145
146 <DT><B>Blt_TreeMoveNode</B> </DT>
147 <DD></DD>
148 </DL>
149
150 <H2><A NAME="sect6" HREF="#toc6">Node Navigation</A></H2>
151 Each
152 node can have zero or more children nodes. These routines let you navigate
153 the tree hierarchy.
154 <DL>
155
156 <DT><B>Blt_TreeNodeParent</B> </DT>
157 <DD>Returns the parent node. </DD>
158
159 <DT><B>Blt_TreeFirstChild</B>
160 </DT>
161 <DD>Returns the first child of a parent node. </DD>
162
163 <DT><B>Blt_TreeLastChild</B> </DT>
164 <DD>Returns the
165 last child of a parent node. </DD>
166
167 <DT><B>Blt_TreeNextSibling</B> </DT>
168 <DD>Returns the next sibling
169 node in the parent's list of children. </DD>
170
171 <DT><B>Blt_TreePrevSibling</B> </DT>
172 <DD>Returns the previous
173 sibling node in the parent's list of children. </DD>
174
175 <DT><B>Blt_TreeRootNode</B> </DT>
176 <DD>Returns the
177 root node of the tree. </DD>
178
179 <DT><B>Blt_TreeNextNode</B> </DT>
180 <DD>Returns the next node in depth-first
181 order. </DD>
182
183 <DT><B>Blt_TreePrevNode</B> </DT>
184 <DD>Returns the previous node in depth-first order. </DD>
185
186 <DT><B>Blt_TreeEndNode</B>
187 </DT>
188 <DD>Returns the last node in the tree as determined by depth-first order. </DD>
189
190 <DT><B>Blt_TreeApply</B>
191 </DT>
192 <DD>Walks through a node and all it descendants, applying a given callback
193 procedure. </DD>
194
195 <DT><B>Blt_TreeApplyDFS</B> </DT>
196 <DD>Walks through a node and all it descendants
197 in depth-first search order, applying a given callback procedure. </DD>
198
199 <DT><B>Blt_TreeApplyBFS</B>
200 </DT>
201 <DD>Walks through a node and all it descendants in breadth-first search order,
202 applying a given callback procedure. </DD>
203 </DL>
204
205 <H2><A NAME="sect7" HREF="#toc7">Node Data Values</A></H2>
206 Data values can be
207 stored at any node. Values have by both a string key and a Tcl_Obj value.
208 Data value keys do not have to be homogenous across all nodes (i.e. nodes
209 do not have to contain the same keys). There is also a special node array
210 data type.
211 <DL>
212
213 <DT><B>Blt_TreeGetValue</B> </DT>
214 <DD>Gets the node data value given by a key. </DD>
215
216 <DT><B>Blt_TreeValueExists</B>
217 </DT>
218 <DD>Indicates if a node data value given by a key exists. </DD>
219
220 <DT><B>Blt_TreeSetValue</B> </DT>
221 <DD>Sets
222 a node's value of a key. </DD>
223
224 <DT><B>Blt_TreeUnsetValue</B> </DT>
225 <DD>Remove the node data value and
226 key. </DD>
227
228 <DT><B>Blt_TreeGetArrayValue</B> </DT>
229 <DD>Gets the node data array value given by a key
230 and an array index. </DD>
231
232 <DT><B>Blt_TreeSetArrayValue</B> </DT>
233 <DD>Sets the node data array value
234 given by a key and an array index. </DD>
235
236 <DT><B>Blt_TreeUnsetArrayValue</B> </DT>
237 <DD>Remove the node
238 data array value. </DD>
239
240 <DT><B>Blt_TreeArrayValueExists</B> </DT>
241 <DD>Determines if an array element
242 by a given index exists. </DD>
243
244 <DT><B>Blt_TreeFirstKey</B> </DT>
245 <DD>Returns the key of the first value
246 in the node. </DD>
247
248 <DT><B>Blt_TreeNextKey</B> </DT>
249 <DD>Returns the key of the next value in the node.
250 </DD>
251
252 <DT><B>Blt_TreePrivateValue</B> </DT>
253 <DD>Lock the value to current client, making it private.
254 </DD>
255
256 <DT><B>Blt_TreePublicValue</B> </DT>
257 <DD>Unlock the value so that all clients can access it.
258 </DD>
259
260 <DT><B>Blt_TreeGetKey</B> </DT>
261 <DD></DD>
262 </DL>
263
264 <H2><A NAME="sect8" HREF="#toc8">Node Traces</A></H2>
265
266 <DL>
267
268 <DT><B>Blt_TreeCreateTrace</B> </DT>
269 <DD>Sets up a trace callback
270 to be invoked when the node value is read, set, or unset. </DD>
271
272 <DT><B>Blt_TreeDeleteTrace</B>
273 </DT>
274 <DD>Deletes an existing trace. </DD>
275 </DL>
276
277 <H2><A NAME="sect9" HREF="#toc9">Node Events</A></H2>
278
279 <DL>
280
281 <DT><B>Blt_TreeCreateEventHandler</B> </DT>
282 <DD>Sets up
283 a callback to be invoked when events (create, delete, relabel, etc) take
284 place on a node. </DD>
285
286 <DT><B>Blt_TreeDeleteEventHandler</B> </DT>
287 <DD>Deletes an existing node callback.
288 </DD>
289 </DL>
290
291 <H2><A NAME="sect10" HREF="#toc10">Keywords</A></H2>
292 alloc, allocation, free, malloc, memory, realloc <P>
293 <P>
294
295 <HR><P>
296 <A NAME="toc"><B>Table of Contents</B></A><P>
297 <UL>
298 <LI><A NAME="toc0" HREF="#sect0">Name</A></LI>
299 <LI><A NAME="toc1" HREF="#sect1">Synopsis</A></LI>
300 <LI><A NAME="toc2" HREF="#sect2">Arguments</A></LI>
301 <LI><A NAME="toc3" HREF="#sect3">Description</A></LI>
302 <LI><A NAME="toc4" HREF="#sect4">Tree Object Routines</A></LI>
303 <LI><A NAME="toc5" HREF="#sect5">Treenode Routines</A></LI>
304 <LI><A NAME="toc6" HREF="#sect6">Node Navigation</A></LI>
305 <LI><A NAME="toc7" HREF="#sect7">Node Data Values</A></LI>
306 <LI><A NAME="toc8" HREF="#sect8">Node Traces</A></LI>
307 <LI><A NAME="toc9" HREF="#sect9">Node Events</A></LI>
308 <LI><A NAME="toc10" HREF="#sect10">Keywords</A></LI>
309 </UL>
310 </BODY></HTML>