Public Member Functions | |
IdTree (unsigned int max) | |
Creates a new, empty map that can hold up to max mappings. | |
~IdTree (void) | |
Destroys the entire map. | |
DisplayableNode * | addDisplayableNode (const NodeAddress &na, GenericNode *node) |
Adds a node to the map. | |
DisplayableNode * | findDisplayableNode (const NodeAddress &na) |
Looks up a DisplayableNode in the map given the node address of the corresponding node. | |
Private Attributes | |
unsigned int | maxMappings |
The maximum number of mappings. | |
NodeAddrMappingPtr * | addrs |
An array with elements that are lists of known node addresses that start with a node ID that is equal to the element's array index. |
In earlier versions, this class was implemented as a tree. Although this is no longer true, the name is kept for compatibility.
All nodes that are displayed by Grisu (which are all instances of DisplayableNode), are assigned a unique node address. The node address is composed of the concatenation of the node ids from the root node of a feature structure or a tree to the node id of the current node (see also the explanation of NodeAddress).
Node addresses are accessed very frequently, especially during painting, where for each node its address must be found at least once.
The basic idea used in this implementation is very similar to a hash table. The mapping makes use of the fact that although many nodes with different node addresses occur in a structure, individual nodes don't occur that often (less than ten times). So the search space can be restricted significantly by looking at the first component in a node address, which is the ID of the node the node address points to. This class maintains an array that contains as many elements as the largest node ID in the structure displayed. (You can think of the ID as the hash key). The array elements point to lists of node addresses that all start with this node ID. If there are multiple node addresses that start with this ID, the right one must be found using a string comparison of the node address.
|
Creates a new, empty map that can hold up to
|
|
Destroys the entire map.
|
|
Adds a node to the map. If the node has been added previously, its corresponding DisplayableNode is returned.
|
|
Looks up a DisplayableNode in the map given the node address of the corresponding node.
|
|
An array with elements that are lists of known node addresses that start with a node ID that is equal to the element's array index.
|
|
The maximum number of mappings.
|