Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

UniConfTree< Sub, Base > Class Template Reference

#include <uniconftree.h>

Inherits Base.

Collaboration diagram for UniConfTree< Sub, Base >:

[legend]
List of all members.

Detailed Description

template<class Sub, class Base = UniHashTreeBase>
class UniConfTree< Sub, Base >

A recursively composed dictionary for ordered tree-structured data indexed by UniConfKey with logarithmic lookup time for each 1-level search, linear insertion and removal.

This container maintains a sorted vector of children which greatly facilitates tree comparison and merging. The underlying collection guarantees fast lookups, but insertion and removal may be quite slow. If this becomes a problem, then a different (more complex) data structure should be used, such as a binary search tree. However, for the moment, the use of a vector keeps down memory footprint.

Someday this could be further abstracted into a generic WvTreeDict.

"Sub" is the name of the concrete subclass of UniConfTree

Definition at line 34 of file uniconftree.h.

Public Types

typedef WvCallback< bool,
const Sub *, const Sub *,
void * > 
Comparator

Public Member Functions

 UniConfTree (Sub *parent, const UniConfKey &key)
 Creates a node and links it to a subtree, if parent is non-NULL.

 ~UniConfTree ()
 Destroy this node's contents and children.

Sub * parent () const
 Returns a pointer to the parent node, or NULL if there is none.

void setparent (Sub *parent)
 Reparents this node.

Sub * root () const
 Returns a pointer to the root node of the tree.

UniConfKey fullkey (const Sub *ancestor=NULL) const
 Returns full path of this node relative to an ancestor.

Sub * find (const UniConfKey &key) const
 Finds the sub-node with the specified key.

Sub * findchild (const UniConfKey &key) const
 Finds the direct child node with the specified key.

void remove (const UniConfKey &key)
 Removes the node for the specified key from the tree and deletes it along with any of its children.

void zap ()
 Removes and deletes all children of this node.

void compare (const Sub *other, const Comparator &comparator, void *userdata)
 Compares this tree with another using the specified comparator function.


Member Typedef Documentation

template<class Sub, class Base = UniHashTreeBase>
typedef WvCallback<bool, const Sub *, const Sub *, void *> UniConfTree< Sub, Base >::Comparator
 

Definition at line 38 of file uniconftree.h.


Constructor & Destructor Documentation

template<class Sub, class Base = UniHashTreeBase>
UniConfTree< Sub, Base >::UniConfTree Sub *  parent,
const UniConfKey key
[inline]
 

Creates a node and links it to a subtree, if parent is non-NULL.

Definition at line 41 of file uniconftree.h.

template<class Sub, class Base = UniHashTreeBase>
UniConfTree< Sub, Base >::~UniConfTree  )  [inline]
 

Destroy this node's contents and children.

Definition at line 46 of file uniconftree.h.


Member Function Documentation

template<class Sub, class Base = UniHashTreeBase>
void UniConfTree< Sub, Base >::compare const Sub *  other,
const Comparator comparator,
void *  userdata
[inline]
 

Compares this tree with another using the specified comparator function.

Comparison of a subtree ends when the comparator returns false. "comparator" is the value compare function "userdata" is userdata for the compare function Returns: true if the comparison function returned true each time

Definition at line 120 of file uniconftree.h.

template<class Sub, class Base = UniHashTreeBase>
Sub* UniConfTree< Sub, Base >::find const UniConfKey key  )  const [inline]
 

Finds the sub-node with the specified key.

If key.isempty(), returns this node.

Definition at line 72 of file uniconftree.h.

Referenced by UniConfTree< UniMountTree >::remove().

template<class Sub, class Base = UniHashTreeBase>
Sub* UniConfTree< Sub, Base >::findchild const UniConfKey key  )  const [inline]
 

Finds the direct child node with the specified key.

If key.numsegments() == 1, then performs the same task as find(key), but a little faster. Otherwise returns NULL.

Definition at line 81 of file uniconftree.h.

template<class Sub, class Base = UniHashTreeBase>
UniConfKey UniConfTree< Sub, Base >::fullkey const Sub *  ancestor = NULL  )  const [inline]
 

Returns full path of this node relative to an ancestor.

If ancestor is NULL, returns the root.

Definition at line 65 of file uniconftree.h.

template<class Sub, class Base = UniHashTreeBase>
Sub* UniConfTree< Sub, Base >::parent  )  const [inline]
 

Returns a pointer to the parent node, or NULL if there is none.

Definition at line 50 of file uniconftree.h.

template<class Sub, class Base = UniHashTreeBase>
void UniConfTree< Sub, Base >::remove const UniConfKey key  )  [inline]
 

Removes the node for the specified key from the tree and deletes it along with any of its children.

If the key is UniConfKey::EMPTY, deletes this object.

Definition at line 90 of file uniconftree.h.

template<class Sub, class Base = UniHashTreeBase>
Sub* UniConfTree< Sub, Base >::root  )  const [inline]
 

Returns a pointer to the root node of the tree.

Definition at line 58 of file uniconftree.h.

template<class Sub, class Base = UniHashTreeBase>
void UniConfTree< Sub, Base >::setparent Sub *  parent  )  [inline]
 

Reparents this node.

Definition at line 54 of file uniconftree.h.

template<class Sub, class Base = UniHashTreeBase>
void UniConfTree< Sub, Base >::zap  )  [inline]
 

Removes and deletes all children of this node.

Definition at line 94 of file uniconftree.h.

Referenced by UniConfTree< UniMountTree >::~UniConfTree().


The documentation for this class was generated from the following file:
Generated on Sat Mar 13 15:00:18 2004 for WvStreams by doxygen 1.3.6-20040222