Fleet  0.0.9
Inference in the LOT
Classes | Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | List of all members
BaseNode< this_t > Class Template Reference

#include <BaseNode.h>

Inheritance diagram for BaseNode< this_t >:
Inheritance graph
[legend]
Collaboration diagram for BaseNode< this_t >:
Collaboration graph
[legend]

Classes

class  NodeIterator
 

Public Member Functions

 BaseNode (size_t n=0, this_t *p=nullptr, size_t i=0)
 Constructor of basenode – sizes children to n. More...
 
 BaseNode (const this_t &n)
 
 BaseNode (this_t &&n)
 
void operator= (const this_t &t)
 
void operator= (const this_t &&t)
 
void make_root ()
 Make a node root – just nulls the parent. More...
 
virtual ~BaseNode ()
 
virtual std::string string (bool usedot=true) const
 
virtual std::string my_string () const
 
virtual bool operator== (const this_t &n) const
 
NodeIterator begin () const
 
NodeIterator end () const
 
virtual bool operator!= (const this_t &n) const
 
void reserve_children (const size_t n)
 
decltype(children) & get_children ()
 
decltype(children) const & get_children () const
 
this_t & child (const size_t i)
 
const this_t & child (const size_t i) const
 
template<typename... Args>
void fill (size_t n, Args... args)
 
size_t nchildren () const
 
this_t * left_descend () const
 
size_t depth () const
 
void fix_child_info ()
 
void check_child_info () const
 
this_t & operator[] (const size_t i)
 
const this_t & operator[] (const size_t i) const
 
void set_child (const size_t i, this_t &n)
 
void set_child (const size_t i, this_t &&n)
 
void push_back (this_t &n)
 
void push_back (this_t &&n)
 
virtual bool is_root () const
 Am I a root node? I am if my parent is nullptr. More...
 
this_t * root ()
 Find the root of this node by walking up the tree. More...
 
this_t * get_via (std::function< bool(this_t &)> &f)
 Return a pointer to the first node satisfying predicate f, in standard traversal; nullptr otherwise. More...
 
virtual size_t count () const
 How many nodes total are below me? More...
 
virtual size_t count (const this_t &n) const
 How many nodes below me are equal to n? More...
 
virtual bool is_terminal () const
 Am I a terminal? I am if I have no children. More...
 
virtual size_t count_terminals () const
 
virtual this_t * get_nth (int n, std::function< int(const this_t &)> &f)
 
virtual this_t * get_nth (int n)
 
template<typename T >
sum (std::function< T(const this_t &)> &f) const
 
template<typename T >
sum (T(*f)(const this_t &)) const
 
bool all (std::function< bool(const this_t &)> &f) const
 
void map (const std::function< void(this_t &)> &f)
 
void show (size_t t=0) const
 

Public Attributes

this_t * parent
 
size_t pi
 

Static Public Attributes

static NodeIterator EndNodeIterator = NodeIterator(nullptr)
 

Protected Attributes

std::vector< this_t > children
 

Detailed Description

template<typename this_t>
class BaseNode< this_t >

Author
piantado
Date
03/07/20

Constructor & Destructor Documentation

◆ BaseNode() [1/3]

template<typename this_t>
BaseNode< this_t >::BaseNode ( size_t  n = 0,
this_t *  p = nullptr,
size_t  i = 0 
)
inline

Constructor of basenode – sizes children to n.

Parameters
n
p
i

◆ BaseNode() [2/3]

template<typename this_t>
BaseNode< this_t >::BaseNode ( const this_t &  n)
inline

◆ BaseNode() [3/3]

template<typename this_t>
BaseNode< this_t >::BaseNode ( this_t &&  n)
inline

◆ ~BaseNode()

template<typename this_t>
virtual BaseNode< this_t >::~BaseNode ( )
inlinevirtual

Member Function Documentation

◆ all()

template<typename this_t>
bool BaseNode< this_t >::all ( std::function< bool(const this_t &)> &  f) const
inline

Check if f is true of me and every node below

Parameters
f
Returns

◆ begin()

template<typename this_t>
NodeIterator BaseNode< this_t >::begin ( ) const
inline

◆ check_child_info()

template<typename this_t>
void BaseNode< this_t >::check_child_info ( ) const
inline

assert that all of the child info is correct

◆ child() [1/2]

template<typename this_t>
this_t& BaseNode< this_t >::child ( const size_t  i)
inline

Get a reference to my i'th child

Parameters
i
Returns

◆ child() [2/2]

template<typename this_t>
const this_t& BaseNode< this_t >::child ( const size_t  i) const
inline

Constant reference to the i'th child

Parameters
i
Returns

◆ count() [1/2]

template<typename this_t>
virtual size_t BaseNode< this_t >::count ( ) const
inlinevirtual

How many nodes total are below me?

Parameters
n
Returns

◆ count() [2/2]

template<typename this_t>
virtual size_t BaseNode< this_t >::count ( const this_t &  n) const
inlinevirtual

How many nodes below me are equal to n?

Parameters
n
Returns

◆ count_terminals()

template<typename this_t>
virtual size_t BaseNode< this_t >::count_terminals ( ) const
inlinevirtual

How many terminals are below me?

Returns

◆ depth()

template<typename this_t>
size_t BaseNode< this_t >::depth ( ) const
inline

◆ end()

template<typename this_t>
NodeIterator BaseNode< this_t >::end ( ) const
inline

◆ fill()

template<typename this_t>
template<typename... Args>
void BaseNode< this_t >::fill ( size_t  n,
Args...  args 
)
inline

Fill in all of my immediate children with Null nodes (via NullRule)

◆ fix_child_info()

template<typename this_t>
void BaseNode< this_t >::fix_child_info ( )
inline

Fix my immediate children's pointers to ensure that children's parent pointers and indices are correct.

◆ get_children() [1/2]

template<typename this_t>
decltype(children) & BaseNode< this_t >::get_children ( )
inline

◆ get_children() [2/2]

template<typename this_t>
decltype(children) const& BaseNode< this_t >::get_children ( ) const
inline

◆ get_nth() [1/2]

template<typename this_t>
virtual this_t* BaseNode< this_t >::get_nth ( int  n,
std::function< int(const this_t &)> &  f 
)
inlinevirtual

Return a pointer to the n'th child satisfying f (f's output is cast to bool)

Parameters
n
f
Returns

◆ get_nth() [2/2]

template<typename this_t>
virtual this_t* BaseNode< this_t >::get_nth ( int  n)
inlinevirtual

◆ get_via()

template<typename this_t>
this_t* BaseNode< this_t >::get_via ( std::function< bool(this_t &)> &  f)
inline

Return a pointer to the first node satisfying predicate f, in standard traversal; nullptr otherwise.

Parameters
f
Returns

◆ is_root()

template<typename this_t>
virtual bool BaseNode< this_t >::is_root ( ) const
inlinevirtual

Am I a root node? I am if my parent is nullptr.

Returns

◆ is_terminal()

template<typename this_t>
virtual bool BaseNode< this_t >::is_terminal ( ) const
inlinevirtual

Am I a terminal? I am if I have no children.

Returns

◆ left_descend()

template<typename this_t>
this_t* BaseNode< this_t >::left_descend ( ) const
inline

Go down a tree and find the leftmost child

Returns

◆ make_root()

template<typename this_t>
void BaseNode< this_t >::make_root ( )
inline

Make a node root – just nulls the parent.

◆ map()

template<typename this_t>
void BaseNode< this_t >::map ( const std::function< void(this_t &)> &  f)
inline

Apply f to me and everything below.

Parameters
f

◆ my_string()

template<typename this_t>
virtual std::string BaseNode< this_t >::my_string ( ) const
inlinevirtual

just print myself, not all my kids (single row per node display)

Reimplemented in BindingTree.

◆ nchildren()

template<typename this_t>
size_t BaseNode< this_t >::nchildren ( ) const
inline

How many children do I have?

Returns

◆ operator!=()

template<typename this_t>
virtual bool BaseNode< this_t >::operator!= ( const this_t &  n) const
inlinevirtual

◆ operator=() [1/2]

template<typename this_t>
void BaseNode< this_t >::operator= ( const this_t &  t)
inline

◆ operator=() [2/2]

template<typename this_t>
void BaseNode< this_t >::operator= ( const this_t &&  t)
inline

◆ operator==()

template<typename this_t>
virtual bool BaseNode< this_t >::operator== ( const this_t &  n) const
inlinevirtual

Reimplemented in Node.

◆ operator[]() [1/2]

template<typename this_t>
this_t& BaseNode< this_t >::operator[] ( const size_t  i)
inline

Index my i'th child

Parameters
i
Returns

◆ operator[]() [2/2]

template<typename this_t>
const this_t& BaseNode< this_t >::operator[] ( const size_t  i) const
inline

◆ push_back() [1/2]

template<typename this_t>
void BaseNode< this_t >::push_back ( this_t &  n)
inline

◆ push_back() [2/2]

template<typename this_t>
void BaseNode< this_t >::push_back ( this_t &&  n)
inline

◆ reserve_children()

template<typename this_t>
void BaseNode< this_t >::reserve_children ( const size_t  n)
inline

◆ root()

template<typename this_t>
this_t* BaseNode< this_t >::root ( )
inline

Find the root of this node by walking up the tree.

Returns

◆ set_child() [1/2]

template<typename this_t>
void BaseNode< this_t >::set_child ( const size_t  i,
this_t &  n 
)
inline

Set my child to n. NOTE: This one needs to be used, rather than accessing children directly, because we have to set parent pointers and indices.

Parameters
i
n

◆ set_child() [2/2]

template<typename this_t>
void BaseNode< this_t >::set_child ( const size_t  i,
this_t &&  n 
)
inline

Child setter for move

Parameters
i

◆ show()

template<typename this_t>
void BaseNode< this_t >::show ( size_t  t = 0) const
inline

◆ string()

template<typename this_t>
virtual std::string BaseNode< this_t >::string ( bool  usedot = true) const
inlinevirtual

Reimplemented in Node, and BindingTree.

◆ sum() [1/2]

template<typename this_t>
template<typename T >
T BaseNode< this_t >::sum ( std::function< T(const this_t &)> &  f) const
inline

Apply f to me and everything below me, adding up the result.

Parameters
f
Returns

◆ sum() [2/2]

template<typename this_t>
template<typename T >
T BaseNode< this_t >::sum ( T(*)(const this_t &)  f) const
inline

Member Data Documentation

◆ children

template<typename this_t>
std::vector<this_t> BaseNode< this_t >::children
protected

◆ EndNodeIterator

template<typename this_t>
BaseNode< this_t >::NodeIterator BaseNode< this_t >::EndNodeIterator = NodeIterator(nullptr)
static

◆ parent

template<typename this_t>
this_t* BaseNode< this_t >::parent

◆ pi

template<typename this_t>
size_t BaseNode< this_t >::pi

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