Class documentation of Concepts

Loading...
Searching...
No Matches
concepts::Joiner< T, nlnk > Class Template Reference

#include <scannerConnectors.hh>

Public Member Functions

 Joiner (const T &val, Joiner *lnk=0)
 
 ~Joiner ()
 
Joiner *& operator[] (uint i)
 
T & value ()
 Returns the content of the container.
 

Static Public Member Functions

static void destructor (Joiner< T, nlnk > *&j, bool values=true)
 

Friends

std::ostream & operator<< (std::ostream &os, const Joiner< T, nlnk > &j)
 

Detailed Description

template<class T, unsigned nlnk>
class concepts::Joiner< T, nlnk >

Joiner class with multiple successors, i.e. it can represent a b-ary tree with b=nlnk. A Joiner is a node in this tree. with b=1 the tree degraded to a forward linked list.

Adding a new node at the beginning of the list is as easy as

Joiner<int, 1>* list;
int a = 2;
list = new Joiner<int, 1>(a, list);

It is not possible to use unique_ptr and Joiner together in a construction like

unique_ptr<Joiner<int, 1> > list;

though. The assignment operator = of unique_ptr releases (ie. deletes) the old object when a new object is assigned. In the statement above, the list on the right hand side would be deleted...

Note
this class would more probably be called BAryTreeNode
Parameters
TClass to be stored
nlnkNumber of successors (ie. links)

Definition at line 73 of file scannerConnectors.hh.

Constructor & Destructor Documentation

◆ Joiner()

template<class T , unsigned nlnk>
concepts::Joiner< T, nlnk >::Joiner ( const T &  val,
Joiner< T, nlnk > *  lnk = 0 
)
inline

Constructor. Fills the container and sets the successors to default of NULL. If a successor is given as argument its filled in as the last successor.

Parameters
valContent of the container.
lnkInitialization value for the last successor.

Definition at line 125 of file scannerConnectors.hh.

◆ ~Joiner()

template<class T , unsigned nlnk>
concepts::Joiner< T, nlnk >::~Joiner ( )
inline

Empty destructor. To delete the list/tree do it by hand or use destructor (only if T pointer).

Definition at line 88 of file scannerConnectors.hh.

Member Function Documentation

◆ destructor()

template<class T , unsigned nlnk>
void concepts::Joiner< T, nlnk >::destructor ( Joiner< T, nlnk > *&  j,
bool  values = true 
)
static

Static function to delete the list/tree. This Function is only valid if T is a pointer type allocated with new().

Parameters
jRoot of the list/tree. It is overwritten with 0

Definition at line 135 of file scannerConnectors.hh.

◆ operator[]()

template<class T , unsigned nlnk>
Joiner *& concepts::Joiner< T, nlnk >::operator[] ( uint  i)
inline

Index operator for the container.

Precondition
i < nlnk
Returns
The ith successor.

Definition at line 101 of file scannerConnectors.hh.

◆ value()

template<class T , unsigned nlnk>
T & concepts::Joiner< T, nlnk >::value ( )
inline

Returns the content of the container.

Definition at line 107 of file scannerConnectors.hh.

Friends And Related Symbol Documentation

◆ operator<<

template<class T , unsigned nlnk>
std::ostream & operator<< ( std::ostream &  os,
const Joiner< T, nlnk > &  j 
)
friend

Definition at line 161 of file scannerConnectors.hh.


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