Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

IdTree Class Reference

This class implements a fast mapping between node addresses and displayable nodes. More...

List of all members.

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.

DisplayableNodeaddDisplayableNode (const NodeAddress &na, GenericNode *node)
 Adds a node to the map.

DisplayableNodefindDisplayableNode (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.

NodeAddrMappingPtraddrs
 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.


Detailed Description

This class implements a fast mapping between node addresses and displayable nodes.

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.

Author:
Holger Wunsch


Constructor & Destructor Documentation

IdTree::IdTree unsigned int  max  ) 
 

Creates a new, empty map that can hold up to max mappings.

Parameters:
max the maximum number of mappings.

IdTree::~IdTree void   ) 
 

Destroys the entire map.


Member Function Documentation

DisplayableNode * IdTree::addDisplayableNode const NodeAddress na,
GenericNode node
 

Adds a node to the map.

If the node has been added previously, its corresponding DisplayableNode is returned.

Parameters:
na the node address of the node
node a pointer to the node data
Returns:
a DisplayableNode representing the visible instance of the node.

DisplayableNode * IdTree::findDisplayableNode const NodeAddress na  ) 
 

Looks up a DisplayableNode in the map given the node address of the corresponding node.

Parameters:
na the node address
Returns:
The DisplayableNode or NULL if the no node wirh the given address exists in the id tree.


Member Data Documentation

NodeAddrMappingPtr* IdTree::addrs [private]
 

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.

unsigned int IdTree::maxMappings [private]
 

The maximum number of mappings.


Generated on Sun Apr 27 18:26:58 2003 for Grisu by doxygen1.3