|
| CMappedTree () |
|
virtual | ~CMappedTree () |
|
virtual CMappedTree< TIdx,
TNode > & | operator= (const CMappedTree< TIdx, TNode > &arg_rhs) |
|
virtual TNode * | create (const TIdx &arg_idx, const TNode &arg_node2add, const bool arg_is_root_) |
|
virtual TNode * | create (const TIdx &arg_idx, const bool arg_is_root_) |
|
virtual TNode * | insert (const TIdx &arg_idx, TNode *arg_node2add, const bool arg_is_root_) |
|
virtual bool | linkNodes () |
|
virtual const TNode * | getRootNodeConst () const |
|
virtual TNode * | getRootNode () |
|
virtual bool | isAncestor (const TIdx &arg_idx_child, const TIdx &arg_idx_ancestor) const |
|
virtual bool | isAncestor (const TNode *arg_node_child, const TNode *arg_node_ancestor) const |
|
virtual bool | isDescendant (const TIdx &arg_idx_parent, const TIdx &arg_idx_descendant) const |
|
virtual bool | isDescendant (const TNode *arg_node_parent, const TNode *arg_node_descendant) const |
|
bool | operator== (const CMappedList< TIdx, TNode > &rhs) |
|
bool | operator!= (const CMappedList< TIdx, TNode > &rhs) |
|
void | swap (CMappedList< TIdx, TNode > &arg_swap_obj) |
|
virtual TNode * | at (const std::size_t arg_idx) |
|
virtual TNode * | at (const TIdx &arg_idx) |
|
virtual const TIdx * | getIndexAt (const std::size_t arg_idx) const |
|
virtual int | getIndexNumericAt (const TIdx &arg_idx) const |
|
virtual int | getIndexNumericAt (const TNode *const arg_node) const |
|
virtual const TNode * | at_const (const std::size_t arg_idx) const |
|
virtual const TNode * | at_const (const TIdx &arg_idx) const |
|
virtual bool | erase (TNode *arg_t) |
|
virtual bool | erase (const TIdx &arg_idx) |
|
virtual std::size_t | size () const |
|
virtual bool | empty () const |
|
virtual bool | clear () |
|
virtual TNode * | operator[] (const std::size_t arg_idx) |
|
iterator | begin () |
|
const_iterator | begin () const |
|
iterator | end () |
|
const_iterator | end () const |
|
virtual bool | sort (const std::vector< TIdx > &arg_order) |
|
virtual bool | sort_get_order (std::vector< TIdx > &ret_order) const |
|
virtual bool | isSorted () const |
|
template<typename TIdx, typename TNode>
class sutil::CMappedTree< TIdx, TNode >
This template class contains a mapped tree.
It is an extension of a MappedList, which itself is a collection of pointers (memory managed) stored in a linked list.
The mapped tree extends the MappedList by using a tree representation where root nodes are connected to subtrees of nodes. This representation is overlaid on the MappedList's linked list so iterating over both is possible. The tree can branch arbitrarily.
The TNode structure MUST contain: a) TIdx name_; b) TIdx parent_name_; c) TNode* parent_addr_; d) std::vector<TNode*> child_addrs_;
NOTE : You MUST call CMappedTree's create functions.
NOTE 2 : You MUST set the name_ and parent_name_ fields for the objects in the mapped tree. The linkNodes function requires this to organize your (unordered) list of nodes into a tree.
template<typename TIdx, typename TNode>
TNode * sutil::CMappedTree< TIdx, TNode >::create |
( |
const TIdx & |
arg_idx, |
|
|
const TNode & |
arg_node2add, |
|
|
const bool |
arg_is_root_ |
|
) |
| |
|
virtual |
Adds a node to the mapped tree. The passed node is copied and stored in a vector. A map between the idx and the node is also stored.
NOTE : Assumes you have set the name_ and parent_name_ fields in the passed arg_node2add
NOTE 2 : There can only be one root node.
Adds a node to the root or child node vectors depending on the type of node to be added.
NOTE : Assumes you have set the name_ and parent_name_ fields in the passed arg_node2add
Passed: node to add, its index name and whether it is a root.
Reimplemented from sutil::CMappedList< TIdx, TNode >.
template<typename TIdx, typename TNode>
TNode * sutil::CMappedTree< TIdx, TNode >::create |
( |
const TIdx & |
arg_idx, |
|
|
const bool |
arg_is_root_ |
|
) |
| |
|
virtual |
Adds a node to the mapped tree.
NOTE : Assumes you will set the name_ and parent_name_ fields in the returned arg_node2add
NOTE 2 : There can only be one root node.
Adds a node to the root or child node vectors depending on the type of node to be added.
Passed: node to add, its index name and whether it is a root.
Reimplemented from sutil::CMappedList< TIdx, TNode >.
template<typename TIdx, typename TNode>
TNode * sutil::CMappedTree< TIdx, TNode >::insert |
( |
const TIdx & |
arg_idx, |
|
|
TNode * |
arg_node2add, |
|
|
const bool |
arg_is_root_ |
|
) |
| |
|
virtual |
Adds an existing object to the mapped tree. The passed node is stored in a vector. A map between the idx and the node is also stored.
NOTE : Assumes you have set the name_ and parent_name_ fields in the passed arg_node2add NOTE 2 : There can only be one root node.
Adds an existing object to the root or child node vectors depending on the type of node to be added.
NOTE : Assumes you have set the name_ and parent_name_ fields in the passed arg_node2add Passed: node to add, its index name and whether it is a root.
Reimplemented from sutil::CMappedList< TIdx, TNode >.
virtual bool sutil::CMappedList< TIdx , TNode >::sort |
( |
const std::vector< TIdx > & |
arg_order | ) |
|
|
virtualinherited |
Sorting related functions
Sorts the list so that iterator access matches the given vector's index. Ie. Given indices 0 to n in the vector, the begin() iterator will match 0, and the end() will appear after iterating over n.
Any create/erase/swap etc. function call will invalidate the sort ordering.
Sorting type : Insertion Sort.