Please enable JavaScript to view this site.

KOL/MCK - User Guide

In order to be able to efficiently store and process data organized in the form of trees in memory, the object type TTree was created (in the KOLadd module).

 

Constructor:

 

NewTree(Parent) or NewTree (Parent, Name) - creates a new node subordinate to the "parent" node Parent (can be nil to create the top-level node). A pointer to the created object, of type PTree, is returned. The first constructor should be used in projects that have the TREE_NONAME conditional compilation symbol. In this case, the tree nodes do not have a Name property and are not intended to hold the string as the main element of the node. In the second case, the constructor (and the corresponding Name property) uses regular strings, or Unicode strings (WideString) can be used.

To switch to using Unicode strings, you must include the TREE_WIDE conditional compilation symbol in your project.

 

 

Methods and properties:

 

Name - node name. As noted, this property does not exist if the project uses the conditional compilation symbol TREE_NONAME;

Data - node data. Generally speaking, any pointer or 32-bit number;

Count - the number of subordinate nodes of the next level (i.e. the number of nodes, the immediate parent of which is this node);

Total - the total number of subordinate nodes of all lower levels (but the node itself is not counted, as for Count);

Items[i] - access to the list of subordinate nodes (the TList object is used in the implementation to store the list of child nodes);

Add(Node) - Adds the specified node to the end of the list of subordinate nodes. If at this moment the node Node was subordinate (to the same, go to some other) node, then it is preliminarily excluded from the list of its previous parent. Thus, you can combine individual trees, or move nodes in the tree together with bunches of child nodes strung on them;

Insert(i, Node)- inserts the specified node into the list of child nodes, at position i. As with the Add method, detaches the inserted node from its previous parent;

SwapNodes(i, j) - swaps nodes with indices i and j places;

SortByName - sorts nodes by name (the Name field must exist);

Parent - parent node;

Index - own index of the node in the list of child nodes of the parent node (Parent);

PrevSibling - returns the pointer of the previous node in the list of child nodes of its parent (or nil if there is no such node);

NextSibling - returns the pointer of the next node in the list of child nodes of its parent (or nil);

Root - returns the pointer of the parent node of the topmost level (for a node that does not have a parent, it itself is returned);

Level - returns the level of the node, i.e. the number of ancestors of the node in the tree hierarchy (0 is returned for the root node);

IsParentOfNode(Node) - checks if the given node is the ancestor of the specified Node in the tree hierarchy;

IndexOf(Node) - returns the "total" index of the child node of any nesting level Node. Note: the total or general index is an index in the array, which is conventionally built as a sequence of all child nodes, each of which is counted along with all its subordinate nodes. It should not be confused with the index of a node in a sibling list;

 

KOL / MCK User Guide - Created by Carl Peeraer - Diamant Soft, based on the work of Vladimir Kladov - Artwerp.be

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Nav Header: ALT+n
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Exit Menu/Up: ESC