Version: 1.0
Classes | Public Member Functions | Public Attributes | Friends | List of all members
BinaryDrag< T > Class Template Reference

A BinaryDrag is the GRAPHGEN implementation of a Binary Directed Rooted Acyclic Graph (DRAG in short) More...

#include <drag.h>

Classes

struct  node
 Defines a node of the BinaryDrag. More...
 

Public Member Functions

template<typename... Args>
nodemake_node (Args &&... args)
 Creates and returns a new node updating the nodes_ vector. More...
 
void AddRoot (node *r)
 Adds a new root to the vector of roots. More...
 
nodeGetRoot () const
 Returns the last root of the BinaryDrag. More...
 
nodeMakeCopyRecursive (node *n, std::unordered_map< node *, node * > &copies)
 Recursive function to copy a BinaryDrag. More...
 
 BinaryDrag ()
 Empty constructor. More...
 
 BinaryDrag (const BinaryDrag &bd)
 Copy constructor. More...
 
 BinaryDrag (const BinaryDrag &bd, std::vector< node * > &tracked_nodes)
 Special copy constructor that allows to track where the nodes in a tree have been copied to. More...
 
 BinaryDrag (BinaryDrag &&t)
 
BinaryDragoperator= (BinaryDrag t)
 Copy assignment. More...
 
nodemake_root ()
 Creates a new root updating the roots_ vector. More...
 

Public Attributes

std::vector< std::unique_ptr< node > > nodes_
 Vector of unique pointers to BinaryDrag nodes. This is useful to automatically free the memory of the BinaryDrag, without requiring a recursive exploration of its structure. More...
 
std::vector< node * > roots_
 

Friends

void swap (BinaryDrag &bd1, BinaryDrag &bd2)
 

Detailed Description

template<typename T>
class BinaryDrag< T >

A BinaryDrag is the GRAPHGEN implementation of a Binary Directed Rooted Acyclic Graph (DRAG in short)

The implementation A BinaryDrag is template on the node data type. A BinaryDrag can be used to model/implement a simple binary tree, a multi-rooted binary tree, a directed acyclic graph with just one root, or a multi-rooted drag. A BinareDrag is the core data structure of GRAPHGEN.

Definition at line 28 of file drag.h.

Constructor & Destructor Documentation

◆ BinaryDrag() [1/4]

template<typename T >
BinaryDrag< T >::BinaryDrag ( )
inline

Empty constructor.

Definition at line 101 of file drag.h.

◆ BinaryDrag() [2/4]

template<typename T >
BinaryDrag< T >::BinaryDrag ( const BinaryDrag< T > &  bd)
inline

Copy constructor.

Definition at line 104 of file drag.h.

◆ BinaryDrag() [3/4]

template<typename T >
BinaryDrag< T >::BinaryDrag ( const BinaryDrag< T > &  bd,
std::vector< node * > &  tracked_nodes 
)
inline

Special copy constructor that allows to track where the nodes in a tree have been copied to.

Definition at line 118 of file drag.h.

◆ BinaryDrag() [4/4]

template<typename T >
BinaryDrag< T >::BinaryDrag ( BinaryDrag< T > &&  t)
inline

Definition at line 134 of file drag.h.

Member Function Documentation

◆ AddRoot()

template<typename T >
void BinaryDrag< T >::AddRoot ( node r)
inline

Adds a new root to the vector of roots.

Definition at line 61 of file drag.h.

◆ GetRoot()

template<typename T >
node* BinaryDrag< T >::GetRoot ( ) const
inline

Returns the last root of the BinaryDrag.

Definition at line 66 of file drag.h.

◆ make_node()

template<typename T >
template<typename... Args>
node* BinaryDrag< T >::make_node ( Args &&...  args)
inline

Creates and returns a new node updating the nodes_ vector.

Definition at line 53 of file drag.h.

◆ make_root()

template<typename T >
node* BinaryDrag< T >::make_root ( )
inline

Creates a new root updating the roots_ vector.

Definition at line 145 of file drag.h.

◆ MakeCopyRecursive()

template<typename T >
node* BinaryDrag< T >::MakeCopyRecursive ( node n,
std::unordered_map< node *, node * > &  copies 
)
inline

Recursive function to copy a BinaryDrag.

This member function is also required by the copy constructor.

Parameters
[in]nThe node address of the BinaryDrag from which start the recursive copy
[in,out]copiesMaps every node address to be copied with its copy address.
Returns
Root address of the new tree.

Definition at line 86 of file drag.h.

◆ operator=()

template<typename T >
BinaryDrag& BinaryDrag< T >::operator= ( BinaryDrag< T >  t)
inline

Copy assignment.

Definition at line 139 of file drag.h.

Friends And Related Function Documentation

◆ swap

template<typename T >
void swap ( BinaryDrag< T > &  bd1,
BinaryDrag< T > &  bd2 
)
friend

Swap member bd1 <-> bd2

Definition at line 71 of file drag.h.

Member Data Documentation

◆ nodes_

template<typename T >
std::vector<std::unique_ptr<node> > BinaryDrag< T >::nodes_

Vector of unique pointers to BinaryDrag nodes. This is useful to automatically free the memory of the BinaryDrag, without requiring a recursive exploration of its structure.

Definition at line 49 of file drag.h.

◆ roots_

template<typename T >
std::vector<node *> BinaryDrag< T >::roots_

Definition at line 58 of file drag.h.


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