Honeycomb
0.1
Component-Model Framework
|
Unrooted acyclic tree. More...
#include <Tree.h>
Classes | |
class | PreOrdIter_ |
Depth-first pre-order traversal. More... | |
Public Types | |
typedef Data_ | Data |
typedef Key_ | Key |
typedef list< deref_wrap< TreeNode >, Alloc< deref_wrap< TreeNode > > > | ChildList |
Child linked list. More... | |
typedef ChildList::iterator | ChildIter |
typedef ChildList::const_iterator | ChildConstIter |
typedef ChildList::reverse_iterator | ChildIterR |
typedef ChildList::const_reverse_iterator | ChildConstIterR |
typedef stdutil::unordered_multimap< Key, deref_wrap< TreeNode >, Alloc > | ChildMap |
Map holding children at keys. More... | |
typedef ChildMap::iterator | ChildMapIter |
typedef ChildMap::const_iterator | ChildMapConstIter |
typedef PreOrdIter_< TreeNode > | PreOrdIter |
typedef PreOrdIter_< const TreeNode > | PreOrdConstIter |
typedef std::reverse_iterator< PreOrdConstIter > | PreOrdConstIterR |
typedef std::reverse_iterator< PreOrdIter > | PreOrdIterR |
Public Member Functions | |
SIGNAL (sigDestroy,(TreeNode &src)) | |
Called before class is destroyed. More... | |
SIGNAL (sigSetData,(TreeNode &src, Data data)) | |
Called after data is set. More... | |
SIGNAL (sigSetKey,(TreeNode &src, Key key)) | |
Called after key is set. More... | |
SIGNAL (sigInsertChild,(TreeNode &src, TreeNode *childPos, TreeNode &child)) | |
Called after child is inserted. More... | |
SIGNAL (sigRemoveChild,(TreeNode &src, TreeNode &child)) | |
Called before child is removed. More... | |
SIGNAL (sigSetParent,(TreeNode &src, TreeNode *parent)) | |
Called before new parent is set (called from parent when inserting/removing child) More... | |
TreeNode () | |
TreeNode (const Data &data) | |
TreeNode (const Data &data, const Key &key) | |
virtual | ~TreeNode () |
void | setData (const Data &data) |
Set the data that this node contains. More... | |
const Data & | getData () const |
Data & | getData () |
operator const Data & () const | |
Implicit cast to the data at this node. More... | |
operator Data & () | |
const Data & | operator* () const |
Get the data at this node. More... | |
Data & | operator* () |
const Data & | operator-> () const |
Data & | operator-> () |
void | setKey (const Key &key) |
Set the key used to identify this node. More... | |
Key & | getKey () |
Get key used to identify this node. More... | |
const Key & | getKey () const |
ChildIter | setParent (TreeNode *parent) |
Set parent node. Returns position in new parent's child list, or children().end() if parent is null. More... | |
const TreeNode * | getParent () const |
Get parent node. More... | |
TreeNode * | getParent () |
bool | hasParent () const |
Check if node has a parent. More... | |
ChildIter | addChild (TreeNode &child) |
Add child into list, returns position of child in list. More... | |
ChildIter | setChild (ChildIter pos, TreeNode &child) |
Set child into list at position. Returns position of child in list. More... | |
ChildIter | insertChild (ChildIter pos, TreeNode &child) |
Insert child into list at position. Returns position of child in list. More... | |
ChildIter | removeChild (TreeNode &child) |
Remove child from children list. Returns position of next child, or children().end() if child doesn't exist. More... | |
ChildIter | removeChild (ChildIter pos) |
Remove child at position in list. Returns position of next child. Will fail if pos is invalid. More... | |
void | clearChildren () |
Clear all children. More... | |
Range_< ChildConstIter, ChildConstIter > | children () const |
Get all children. More... | |
Range_< ChildIter, ChildIter > | children () |
Range_< ChildConstIterR, ChildConstIterR > | childrenR () const |
Get all children in reverse order. More... | |
Range_< ChildIterR, ChildIterR > | childrenR () |
szt | childCount () const |
Get number of children. More... | |
bool | hasChildren () const |
Check if node has children. More... | |
ChildConstIter | childPos (const Key &key) const |
Get child position in list. Returns first child found at key, or children().end() if not found. More... | |
ChildIter | childPos (const Key &key) |
ChildConstIter | childPos (const TreeNode &child) const |
Get child position in list. Returns children().end() if not in parent. More... | |
ChildIter | childPos (const TreeNode &child) |
const TreeNode * | child (const Key &key) const |
Get child in list. Returns first child found at key, or null if not found. More... | |
TreeNode * | child (const Key &key) |
bool | hasChild (const TreeNode &child) const |
Check if this node has a child in its list. More... | |
Range_< ChildMapIter, ChildMapIter > | children (const Key &key) |
Get children that match the key. The child node TreeNode& is stored in the map pair ChildMapIter->second . More... | |
Range_< ChildMapConstIter, ChildMapConstIter > | children (const Key &key) const |
Range_< ChildConstIter, ChildConstIter > | sibNext () const |
Returns forward iterator range starting at next sibling. More... | |
Range_< ChildIter, ChildIter > | sibNext () |
Range_< ChildConstIterR, ChildConstIterR > | sibPrev () const |
Returns reverse iterator range starting at previous sibling. More... | |
Range_< ChildIterR, ChildIterR > | sibPrev () |
szt | sibCount () const |
Get number of siblings (count doesn't include this node) More... | |
bool | sibHasNext () const |
Check if node has a next sibling. More... | |
bool | sibHasPrev () const |
Check if node has a previous sibling. More... | |
const TreeNode & | root () const |
Get the root (top-most) node of the tree that contains this node. More... | |
TreeNode & | root () |
bool | isRoot () const |
Check if this is a root node at the top of a tree. More... | |
bool | isLeaf () const |
Check if this is a leaf node at the end of a tree branch. More... | |
bool | isAncestor (const TreeNode &ancestor) const |
Test if ancestor is this node's ancestor. Returns false if ancestor is same as this node. More... | |
bool | isAncestorOf (const TreeNode &node) const |
Test if this node is an ancestor of node. Returns false if node is same as this node. More... | |
const TreeNode * | findNode (const Key &key) const |
Returns first node found with key in tree of descendants (depth-first pre-order traversal) More... | |
TreeNode * | findNode (const Key &key) |
Range_< PreOrdConstIter, PreOrdConstIter > | preOrd () const |
Get a depth-first pre-order range. More... | |
Range_< PreOrdIter, PreOrdIter > | preOrd () |
Range_< PreOrdConstIterR, PreOrdConstIterR > | preOrdR () const |
Get a reversed depth-first pre-order range. More... | |
Range_< PreOrdIterR, PreOrdIterR > | preOrdR () |
ListenerList & | listeners () |
Get listener list. More... | |
Friends | |
template<class , class , template< class > class> | |
class | TreeNode |
Unrooted acyclic tree.
Every tree node has one parent node, multiple children, and a generic data value. Nodes may contain a key for identification and fast retrieval. The key doesn't have to be unique.
typedef ChildList::const_iterator honey::TreeNode< Data_, Key_, Alloc >::ChildConstIter |
typedef ChildList::const_reverse_iterator honey::TreeNode< Data_, Key_, Alloc >::ChildConstIterR |
typedef ChildList::iterator honey::TreeNode< Data_, Key_, Alloc >::ChildIter |
typedef ChildList::reverse_iterator honey::TreeNode< Data_, Key_, Alloc >::ChildIterR |
typedef list<deref_wrap<TreeNode>, Alloc<deref_wrap<TreeNode> > > honey::TreeNode< Data_, Key_, Alloc >::ChildList |
Child linked list.
typedef stdutil::unordered_multimap<Key, deref_wrap<TreeNode>, Alloc> honey::TreeNode< Data_, Key_, Alloc >::ChildMap |
Map holding children at keys.
typedef ChildMap::const_iterator honey::TreeNode< Data_, Key_, Alloc >::ChildMapConstIter |
typedef ChildMap::iterator honey::TreeNode< Data_, Key_, Alloc >::ChildMapIter |
typedef Data_ honey::TreeNode< Data_, Key_, Alloc >::Data |
typedef Key_ honey::TreeNode< Data_, Key_, Alloc >::Key |
typedef PreOrdIter_<const TreeNode> honey::TreeNode< Data_, Key_, Alloc >::PreOrdConstIter |
typedef std::reverse_iterator<PreOrdConstIter> honey::TreeNode< Data_, Key_, Alloc >::PreOrdConstIterR |
typedef PreOrdIter_<TreeNode> honey::TreeNode< Data_, Key_, Alloc >::PreOrdIter |
typedef std::reverse_iterator<PreOrdIter> honey::TreeNode< Data_, Key_, Alloc >::PreOrdIterR |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
|
inline |
Add child into list, returns position of child in list.
|
inline |
Get child in list. Returns first child found at key, or null if not found.
|
inline |
|
inline |
Get number of children.
|
inline |
Get child position in list. Returns first child found at key, or children().end() if not found.
|
inline |
|
inline |
Get child position in list. Returns children().end() if not in parent.
|
inline |
|
inline |
Get all children.
|
inline |
|
inline |
Get children that match the key. The child node TreeNode&
is stored in the map pair ChildMapIter->second
.
|
inline |
|
inline |
Get all children in reverse order.
|
inline |
|
inline |
Clear all children.
|
inline |
Returns first node found with key in tree of descendants (depth-first pre-order traversal)
|
inline |
|
inline |
|
inline |
|
inline |
Get key used to identify this node.
|
inline |
|
inline |
Get parent node.
|
inline |
|
inline |
Check if this node has a child in its list.
|
inline |
Check if node has children.
|
inline |
Check if node has a parent.
|
inline |
Insert child into list at position. Returns position of child in list.
|
inline |
Test if ancestor
is this node's ancestor. Returns false if ancestor
is same as this node.
|
inline |
Test if this node is an ancestor of node. Returns false if node
is same as this node.
|
inline |
Check if this is a leaf node at the end of a tree branch.
|
inline |
Check if this is a root node at the top of a tree.
|
inline |
Get listener list.
|
inline |
Implicit cast to the data at this node.
|
inline |
|
inline |
Get the data at this node.
|
inline |
|
inline |
|
inline |
|
inline |
Get a depth-first pre-order range.
|
inline |
|
inline |
Get a reversed depth-first pre-order range.
|
inline |
|
inline |
Remove child from children list. Returns position of next child, or children().end() if child doesn't exist.
|
inline |
Remove child at position in list. Returns position of next child. Will fail if pos is invalid.
|
inline |
Get the root (top-most) node of the tree that contains this node.
|
inline |
|
inline |
Set child into list at position. Returns position of child in list.
|
inline |
Set the data that this node contains.
|
inline |
Set the key used to identify this node.
|
inline |
Set parent node. Returns position in new parent's child list, or children().end() if parent is null.
|
inline |
Get number of siblings (count doesn't include this node)
|
inline |
Check if node has a next sibling.
|
inline |
Check if node has a previous sibling.
|
inline |
Returns forward iterator range starting at next sibling.
|
inline |
|
inline |
Returns reverse iterator range starting at previous sibling.
|
inline |
honey::TreeNode< Data_, Key_, Alloc >::SIGNAL | ( | sigDestroy | , |
(TreeNode< Data_, Key_, Alloc > &src) | |||
) |
Called before class is destroyed.
honey::TreeNode< Data_, Key_, Alloc >::SIGNAL | ( | sigSetData | , |
(TreeNode< Data_, Key_, Alloc > &src, Data data) | |||
) |
Called after data is set.
honey::TreeNode< Data_, Key_, Alloc >::SIGNAL | ( | sigSetKey | , |
(TreeNode< Data_, Key_, Alloc > &src, Key key) | |||
) |
Called after key is set.
honey::TreeNode< Data_, Key_, Alloc >::SIGNAL | ( | sigInsertChild | , |
(TreeNode< Data_, Key_, Alloc > &src, TreeNode< Data_, Key_, Alloc > *childPos, TreeNode< Data_, Key_, Alloc > &child) | |||
) |
Called after child is inserted.
honey::TreeNode< Data_, Key_, Alloc >::SIGNAL | ( | sigRemoveChild | , |
(TreeNode< Data_, Key_, Alloc > &src, TreeNode< Data_, Key_, Alloc > &child) | |||
) |
Called before child is removed.
honey::TreeNode< Data_, Key_, Alloc >::SIGNAL | ( | sigSetParent | , |
(TreeNode< Data_, Key_, Alloc > &src, TreeNode< Data_, Key_, Alloc > *parent) | |||
) |
Called before new parent is set (called from parent when inserting/removing child)
|
friend |