SCL  1.0
Standard Control Library : Control, dynamics, physics, and simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
sutil::CMappedDirGraph< TIdx, TNode > Class Template Reference

#include <CMappedDirGraph.hpp>

Inheritance diagram for sutil::CMappedDirGraph< TIdx, TNode >:
Inheritance graph
[legend]
Collaboration diagram for sutil::CMappedDirGraph< TIdx, TNode >:
Collaboration graph
[legend]

Classes

struct  SMGNodeBase
 

Public Types

typedef size_t size_type
 
typedef ptrdiff_t difference_type
 
typedef TNode * pointer
 
typedef const TNode * const_pointer
 
typedef TNode & reference
 
typedef const TNode & const_reference
 
typedef TNode value_type
 

Public Member Functions

virtual bool linkNodes ()
 
virtual bool genSpanningTree ()
 
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 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
 

Public Attributes

std::vector< std::pair< TNode
*, TNode * > > 
st_broken_edges_
 

Protected Member Functions

virtual bool deepCopy (const CMappedTree< TIdx, TNode > *arg_mt)
 
virtual bool deepCopy (const CMappedList< TIdx, TNode > *const arg_pmap)
 

Protected Attributes

TNode * root_node_
 
bool has_been_init_
 
SMLNode< TIdx, TNode > * front_
 
SMLNode< TIdx, TNode > * back_
 
SMLNode< TIdx, TNode > null_
 
std::map< TIdx, SMLNode< TIdx,
TNode > * > 
map_
 
std::size_t size_
 
std::vector< TIdx > sorting_order_
 
bool flag_is_sorted_
 

Detailed Description

template<typename TIdx, typename TNode>
class sutil::CMappedDirGraph< TIdx, TNode >

This template class contains a mapped graph.

It is an extension of a MappedTree, which itself is a collection of pointers (memory managed) stored in a tree (which is further stored in a linked list).

The mapped graph extends the MappedTree by using a graph representation where root nodes are connected to subgraphs of nodes. This representation is overlaid on the MappedTree's tree so iterating over both is possible. The graph can branch arbitrarily.

The TNode structure MUST contain (in addition to MappedTree's node requirements): a) std::vector<TIdx> parent_names_; b) std::vector<TNode*> parent_addrs_; c) std::vector<TNode*> child_addrs_;

NOTE : You MUST call CMappedDirGraph's create functions.

NOTE 2 : You MUST set the name_ and parent_names_ fields for the objects in the mapped graph. The linkNodes function requires this to organize your (unordered) list of nodes into a graph.

Member Typedef Documentation

typedef size_t sutil::CMappedList< TIdx , TNode >::size_type
inherited

STL container specific code: (a) A set of typedefs (b) An iterator definition (c) Standard methods



The standard stl typedefs:


Member Function Documentation

virtual TNode * sutil::CMappedList< TIdx , TNode >::at ( const std::size_t  arg_idx)
virtualinherited

Returns the element at the given numerical index in the linked list (usually useful only for debugging)

NOTE : The index starts at 0

virtual TNode * sutil::CMappedList< TIdx , TNode >::at ( const TIdx &  arg_idx)
virtualinherited

Returns the element referenced by the index

NOTE : This uses the std::map (and is somewhat slow)

virtual const TNode * sutil::CMappedList< TIdx , TNode >::at_const ( const std::size_t  arg_idx) const
virtualinherited

Returns the element at the given numerical index in the linked list (usually useful only for debugging)

NOTE : The index starts at 0

virtual const TNode * sutil::CMappedList< TIdx , TNode >::at_const ( const TIdx &  arg_idx) const
virtualinherited

Returns a const pointer to the element referenced by the index

NOTE : This uses the std::map (and is rather slow)

iterator sutil::CMappedList< TIdx , TNode >::begin ( )
inlineinherited

The iterator functions


virtual bool sutil::CMappedList< TIdx , TNode >::clear ( )
virtualinherited

Clears all elements from the list

template<typename TIdx, typename TNode>
TNode * sutil::CMappedTree< TIdx, TNode >::create ( const TIdx &  arg_idx,
const TNode &  arg_node2add,
const bool  arg_is_root_ 
)
virtualinherited

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_ 
)
virtualinherited

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>
bool sutil::CMappedTree< TIdx, TNode >::deepCopy ( const CMappedTree< TIdx, TNode > *  arg_mt)
protectedvirtualinherited

Copy-Constructor : Does a deep copy of the mapped tree to get a new one.

NOTE : This uses the passed mappedlist's iterator construct.

virtual bool sutil::CMappedList< TIdx , TNode >::deepCopy ( const CMappedList< TIdx , TNode > *const  arg_pmap)
protectedvirtualinherited

Does a deep copy of the mappedlist to get a new one. This is VERY SLOW.

virtual bool sutil::CMappedList< TIdx , TNode >::empty ( ) const
inlinevirtualinherited

Is the container empty

virtual bool sutil::CMappedList< TIdx , TNode >::erase ( TNode *  arg_t)
virtualinherited

Erases an element from the list. Referenced by the element's memory location

virtual bool sutil::CMappedList< TIdx , TNode >::erase ( const TIdx &  arg_idx)
virtualinherited

Erases an element from the list. Referenced by its std::map index

NOTE : This uses the std::map (and is rather slow)

template<typename TIdx , typename TNode >
bool sutil::CMappedDirGraph< TIdx, TNode >::genSpanningTree ( )
virtual

Generates the spanning tree for the graph and store it in the mapped tree pointer structure

Generates the spanning tree for the graph and stores it in the mapped tree pointer structure

NOTE TODO : Make this function more efficient.

virtual const TIdx * sutil::CMappedList< TIdx , TNode >::getIndexAt ( const std::size_t  arg_idx) const
virtualinherited

Returns the typed index at the given numerical index in the linked list

NOTE : The index starts at 0

virtual int sutil::CMappedList< TIdx , TNode >::getIndexNumericAt ( const TIdx &  arg_idx) const
virtualinherited

Returns the numeric index at the given typed index in the linked list

NOTE : The index starts at 0. Returns -1 if node not found.

Returns the numeric index at the given typed index in the linked list

virtual int sutil::CMappedList< TIdx , TNode >::getIndexNumericAt ( const TNode *const  arg_node) const
virtualinherited

Returns the numeric index at the given typed index in the linked list

NOTE : The index starts at 0. Returns -1 if node not found.

Returns the numeric index at the given typed index in the linked list

template<typename TIdx, typename TNode>
virtual TNode* sutil::CMappedTree< TIdx, TNode >::getRootNode ( )
inlinevirtualinherited

Returns a pointer to the root node

template<typename TIdx, typename TNode>
virtual const TNode* sutil::CMappedTree< TIdx, TNode >::getRootNodeConst ( ) const
inlinevirtualinherited

Returns a pointer to the root node

template<typename TIdx, typename TNode>
TNode * sutil::CMappedTree< TIdx, TNode >::insert ( const TIdx &  arg_idx,
TNode *  arg_node2add,
const bool  arg_is_root_ 
)
virtualinherited

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

template<typename TIdx, typename TNode >
bool sutil::CMappedTree< TIdx, TNode >::isAncestor ( const TIdx &  arg_idx_child,
const TIdx &  arg_idx_ancestor 
) const
virtualinherited

Determines if the child has the other node as an ancestor

template<typename TIdx, typename TNode>
bool sutil::CMappedTree< TIdx, TNode >::isAncestor ( const TNode *  arg_node_child,
const TNode *  arg_node_ancestor 
) const
virtualinherited

Determines if the child has the other node as an ancestor

template<typename TIdx, typename TNode >
bool sutil::CMappedTree< TIdx, TNode >::isDescendant ( const TIdx &  arg_idx_parent,
const TIdx &  arg_idx_descendant 
) const
virtualinherited

Determines if the parent has the other node as a descendant in the tree

Determines if the parent has the other node as a descendant

template<typename TIdx, typename TNode>
bool sutil::CMappedTree< TIdx, TNode >::isDescendant ( const TNode *  arg_node_parent,
const TNode *  arg_node_descendant 
) const
virtualinherited

Determines if the parent has the other node as a descendant in the tree

Determines if the parent has the other node as a descendant

virtual bool sutil::CMappedList< TIdx , TNode >::isSorted ( ) const
inlinevirtualinherited

Whether the list has been sorted or not

template<typename TIdx , typename TNode >
bool sutil::CMappedDirGraph< TIdx, TNode >::linkNodes ( )
virtual

Organizes the links into a graph.

Organizes all the links in the graph by connecting them to their parents. Also creates a spanning tree for the graph.

O(n*log(n))

Reimplemented from sutil::CMappedTree< TIdx, TNode >.

bool sutil::CMappedList< TIdx , TNode >::operator!= ( const CMappedList< TIdx , TNode > &  rhs)
inherited

Comparison operator : Performs an element-by-element check (std container requirement). Beware; This can be quite slow.

bool sutil::CMappedList< TIdx , TNode >::operator== ( const CMappedList< TIdx , TNode > &  rhs)
inherited

Comparison operator : Performs an element-by-element check (std container requirement). Beware; This can be quite slow.

virtual TNode * sutil::CMappedList< TIdx , TNode >::operator[] ( const std::size_t  arg_idx)
inlinevirtualinherited

Typical operator access

virtual std::size_t sutil::CMappedList< TIdx , TNode >::size ( ) const
inlinevirtualinherited

Returns the size of the mapped list

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.

virtual bool sutil::CMappedList< TIdx , TNode >::sort_get_order ( std::vector< TIdx > &  ret_order) const
inlinevirtualinherited

Get the sorting order if there is one

void sutil::CMappedList< TIdx , TNode >::swap ( CMappedList< TIdx , TNode > &  arg_swap_obj)
inherited

Swaps the elements with the passed pilemap

Member Data Documentation

SMLNode<TIdx ,TNode >* sutil::CMappedList< TIdx , TNode >::back_
protectedinherited

Pointer to the tail/back/dangling-end of the list

bool sutil::CMappedList< TIdx , TNode >::flag_is_sorted_
protectedinherited

Whether the list is sorted or not

SMLNode<TIdx ,TNode >* sutil::CMappedList< TIdx , TNode >::front_
protectedinherited

Mapped List Data


Pointer to the head/front/insertion-end of the list

template<typename TIdx, typename TNode>
bool sutil::CMappedTree< TIdx, TNode >::has_been_init_
protectedinherited

True if the mapped tree has a root.

std::map<TIdx , SMLNode<TIdx ,TNode >*> sutil::CMappedList< TIdx , TNode >::map_
protectedinherited

The map that will enable Idx based data lookup

SMLNode<TIdx ,TNode > sutil::CMappedList< TIdx , TNode >::null_
protectedinherited

Pointer to the element obtained with the end() call. Does not exist in the map.

template<typename TIdx, typename TNode>
TNode* sutil::CMappedTree< TIdx, TNode >::root_node_
protectedinherited

The root of the mapped tree

std::size_t sutil::CMappedList< TIdx , TNode >::size_
protectedinherited

The size of the MappedList

std::vector<TIdx > sutil::CMappedList< TIdx , TNode >::sorting_order_
protectedinherited

An index that specifies a sort ordering if required

template<typename TIdx , typename TNode >
std::vector<std::pair<TNode*, TNode*> > sutil::CMappedDirGraph< TIdx, TNode >::st_broken_edges_

These are the edges broken while creating the spanning tree (useful for solving constraints etc. in closed loop / recurrent systems)


The documentation for this class was generated from the following file: