Joiner class with multiple successors, i.e. More...

#include <scannerConnectors.hh>

Public Member Functions

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

Static Public Member Functions

static void destructor (Joiner< T, nlnk > *&j, bool values=true)
 Static function to delete the list/tree. More...
 

Private Member Functions

 Joiner (const Joiner &)
 Copy constructor. More...
 
void operator= (const Joiner &)
 

Static Private Member Functions

static void destructor_ (Joiner< T, nlnk > *j, bool values=true)
 Recursive destructor. More...
 

Private Attributes

Joiner< T, nlnk > * lnk_ [nlnk]
 Array of the successors. More...
 
val_
 The content of the container. More...
 

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 47 of file scannerConnectors.hh.

Constructor & Destructor Documentation

◆ Joiner() [1/2]

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.

◆ Joiner() [2/2]

template<class T , unsigned nlnk>
concepts::Joiner< T, nlnk >::Joiner ( const Joiner< T, nlnk > &  )
private

Copy constructor.

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.

◆ destructor_()

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

Recursive destructor.

Definition at line 152 of file scannerConnectors.hh.

◆ operator=()

template<class T , unsigned nlnk>
void concepts::Joiner< T, nlnk >::operator= ( const Joiner< T, nlnk > &  )
private

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

Member Data Documentation

◆ lnk_

template<class T , unsigned nlnk>
Joiner<T, nlnk>* concepts::Joiner< T, nlnk >::lnk_[nlnk]
private

Array of the successors.

Definition at line 111 of file scannerConnectors.hh.

◆ val_

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

The content of the container.

Definition at line 114 of file scannerConnectors.hh.


The documentation for this class was generated from the following file:
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich