Herwig 7.3.0
|
binary_tree represents a binary tree with the ability to ‘cascade’ visitor objects down the tree More...
#include <binary_tree.h>
Classes | |
class | const_iterator |
const_iterator More... | |
struct | istream_generator |
generator reading binary tree from istream More... | |
class | iterator |
iterator More... | |
struct | ostream_visitor |
forward visitor writing out the tree to given ostream More... | |
Public Types | |
type definitions | |
typedef Value | value_type |
define the object type | |
Public Member Functions | |
constructors | |
binary_tree () | |
default constructor | |
binary_tree (const value_type &thevalue, binary_tree *theparent=0) | |
construct giving key/cell and parent | |
binary_tree (const binary_tree &x) | |
binary_tree has a strict ownership; on copying binary trees ownership is transferred | |
binary_tree & | operator= (const binary_tree &x) |
binary_tree has a strict ownership; on copying binary trees ownership is transferred | |
Public member access | |
value_type & | value () |
return the value held by this node | |
const value_type & | value () const |
return the value held by this node | |
bool | root () const |
return true, if this is the root node | |
bool | leaf () const |
return true, if this node has got children | |
standard-conforming leaf iterators | |
std::pair< binary_tree *, binary_tree * > | neighbours_ |
the left and right neighbours of this node | |
iterator | begin () |
return begin iterator | |
iterator | end () |
return end iterator | |
iterator | global_begin () |
return global begin iterator | |
iterator | global_end () |
return global end iterator | |
const_iterator | begin () const |
return begin const_iterator | |
const_iterator | end () const |
return end const_iterator | |
const_iterator | global_begin () const |
return global begin iterator | |
const_iterator | global_end () const |
return global end iterator | |
bool | empty () const |
return true, if this node is empty | |
void | clear () |
clear this node | |
std::pair< iterator, iterator > | split (std::pair< value_type, value_type > children) |
split this node | |
template<class Selector > | |
iterator | select (const Selector &selector) |
select using a selector | |
template<class Selector , unsigned long bits> | |
void | subtree_hash (const Selector &selector, bit_container< bits > &bhash) |
generate a hash value for the sub-tree selected by the given selector object | |
template<class Accessor , class BinaryOp > | |
BinaryOp::result_type | accumulate (const Accessor &acc, BinaryOp binary_op) const |
accumulate values using a binary function and accessor object | |
template<class Selector , class Accessor , class BinaryOp > | |
BinaryOp::result_type | accumulate (const Selector &selector, const Accessor &acc, BinaryOp binary_op) const |
accumulate values only from branches matching a Selector | |
template<class Accessor , class BinaryOp > | |
BinaryOp::result_type | tree_accumulate (const Accessor &acc, BinaryOp binary_op) |
accumulate values using a binary function and accessor object, storing intermediate values in nodes | |
template<class Selector , class Accessor , class BinaryOp > | |
BinaryOp::result_type | tree_accumulate (const Selector &selector, const Accessor &acc, BinaryOp binary_op) |
accumulate values only from branches matching a Selector | |
template<class Visitor > | |
void | cascade (Visitor visitor) const |
forward propagate a visitor to all children nodes | |
template<class Generator > | |
void | generate (Generator generator) |
succesively split using a generator | |
void | left_neighbour (binary_tree *n) |
set the left neighbour | |
void | right_neighbour (binary_tree *n) |
set the right neighbour | |
binary_tree * | left_neighbour () const |
get the left neighbour | |
binary_tree * | right_neighbour () const |
get the right neighbour | |
binary_tree * | left_most () |
return the left-most leaf | |
binary_tree * | right_most () |
return the right-most leaf | |
const binary_tree * | left_most () const |
return the left-most leaf | |
const binary_tree * | right_most () const |
return the right-most leaf | |
private member access | |
binary_tree * | parent_ |
the parent of this node | |
std::unique_ptr< value_type > | value_ |
the cell held by this node | |
std::pair< std::unique_ptr< binary_tree >, std::unique_ptr< binary_tree > > | children_ |
the children of this node | |
binary_tree & | parent () |
return the parent of this node | |
const binary_tree & | parent () const |
return the parent of this node | |
binary_tree & | left_child () |
return the left child of this node | |
const binary_tree & | left_child () const |
return the left child of this node | |
binary_tree & | right_child () |
return the right child of this node | |
const binary_tree & | right_child () const |
return the right child of this node | |
put and get from streams | |
template<class OStream > | |
void | put (OStream &os) const |
put to ostream | |
template<class IStream > | |
void | get (IStream &is) |
get from istream | |
template<class Selector , unsigned long bits> | |
void | do_subtree_hash (const Selector &selector, bit_container< bits > ¤t, unsigned long &position, bool selected=true) const |
calculate hash value | |
binary_tree represents a binary tree with the ability to ‘cascade’ visitor objects down the tree
Definition at line 21 of file binary_tree.h.
typedef Value exsample::binary_tree< Value >::value_type |
define the object type
Definition at line 29 of file binary_tree.h.
|
inline |
default constructor
Definition at line 39 of file binary_tree.h.
Referenced by exsample::binary_tree< Value >::split().
|
inline |
construct giving key/cell and parent
Definition at line 46 of file binary_tree.h.
|
inline |
binary_tree has a strict ownership; on copying binary trees ownership is transferred
Definition at line 55 of file binary_tree.h.
References exsample::binary_tree< Value >::children_, exsample::binary_tree< Value >::neighbours_, exsample::binary_tree< Value >::parent_, exsample::binary_tree< Value >::root(), and exsample::binary_tree< Value >::value_.
|
inline |
accumulate values using a binary function and accessor object
Definition at line 525 of file binary_tree.h.
References exsample::binary_tree< Value >::accumulate(), exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::left_child(), exsample::binary_tree< Value >::right_child(), and exsample::binary_tree< Value >::value().
Referenced by exsample::binary_tree< Value >::accumulate().
|
inline |
accumulate values only from branches matching a Selector
Definition at line 541 of file binary_tree.h.
References exsample::binary_tree< Value >::accumulate(), exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::left_child(), exsample::binary_tree< Value >::right_child(), and exsample::binary_tree< Value >::value().
|
inline |
return begin iterator
Definition at line 225 of file binary_tree.h.
References exsample::binary_tree< Value >::left_most().
|
inline |
return begin const_iterator
Definition at line 371 of file binary_tree.h.
References exsample::binary_tree< Value >::left_most().
|
inline |
forward propagate a visitor to all children nodes
Definition at line 611 of file binary_tree.h.
References exsample::binary_tree< Value >::cascade(), exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::left_child(), exsample::binary_tree< Value >::right_child(), and exsample::binary_tree< Value >::value().
Referenced by exsample::binary_tree< Value >::cascade(), and exsample::binary_tree< Value >::put().
|
inline |
clear this node
Definition at line 439 of file binary_tree.h.
References exsample::binary_tree< Value >::children_, exsample::binary_tree< Value >::clear(), exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::left_child(), exsample::binary_tree< Value >::neighbours_, exsample::binary_tree< Value >::parent_, exsample::binary_tree< Value >::right_child(), and exsample::binary_tree< Value >::value_.
Referenced by exsample::binary_tree< Value >::clear().
|
inlineprivate |
calculate hash value
Definition at line 814 of file binary_tree.h.
References exsample::bit_container< bits >::bit(), exsample::binary_tree< Value >::do_subtree_hash(), exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::left_child(), exsample::binary_tree< Value >::right_child(), and exsample::binary_tree< Value >::value().
Referenced by exsample::binary_tree< Value >::do_subtree_hash().
|
inline |
return true, if this node is empty
Definition at line 436 of file binary_tree.h.
References exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::root(), and exsample::binary_tree< Value >::value_.
Referenced by exsample::binary_tree< Value >::get(), and exsample::binary_tree< Value >::put().
|
inline |
return end iterator
Definition at line 228 of file binary_tree.h.
References exsample::binary_tree< Value >::right_most().
|
inline |
return end const_iterator
Definition at line 374 of file binary_tree.h.
References exsample::binary_tree< Value >::right_most().
|
inline |
succesively split using a generator
Definition at line 622 of file binary_tree.h.
References exsample::generator< Function, Random >::generate(), exsample::binary_tree< Value >::root(), exsample::generator< Function, Random >::split(), exsample::binary_tree< Value >::split(), exsample::binary_tree< Value >::value(), and exsample::binary_tree< Value >::value_.
Referenced by exsample::binary_tree< Value >::get().
|
inline |
get from istream
Definition at line 788 of file binary_tree.h.
References exsample::binary_tree< Value >::empty(), exsample::binary_tree< Value >::generate(), exsample::binary_tree< Value >::value(), and exsample::binary_tree< Value >::value_.
|
inline |
return global begin iterator
Definition at line 231 of file binary_tree.h.
References exsample::binary_tree< Value >::global_begin(), exsample::binary_tree< Value >::left_most(), exsample::binary_tree< Value >::parent(), and exsample::binary_tree< Value >::root().
Referenced by exsample::binary_tree< Value >::global_begin().
|
inline |
return global begin iterator
Definition at line 377 of file binary_tree.h.
References exsample::binary_tree< Value >::global_begin(), exsample::binary_tree< Value >::left_most(), exsample::binary_tree< Value >::parent(), and exsample::binary_tree< Value >::root().
|
inline |
return global end iterator
Definition at line 238 of file binary_tree.h.
References exsample::binary_tree< Value >::global_end(), exsample::binary_tree< Value >::parent(), exsample::binary_tree< Value >::right_most(), and exsample::binary_tree< Value >::root().
Referenced by exsample::binary_tree< Value >::global_end(), and exsample::binary_tree< Value >::select().
|
inline |
return global end iterator
Definition at line 384 of file binary_tree.h.
References exsample::binary_tree< Value >::global_end(), exsample::binary_tree< Value >::parent(), exsample::binary_tree< Value >::right_most(), and exsample::binary_tree< Value >::root().
|
inline |
return true, if this node has got children
Definition at line 647 of file binary_tree.h.
References exsample::binary_tree< Value >::children_.
Referenced by exsample::binary_tree< Value >::accumulate(), exsample::binary_tree< Value >::cascade(), exsample::binary_tree< Value >::clear(), exsample::binary_tree< Value >::do_subtree_hash(), exsample::binary_tree< Value >::empty(), exsample::binary_tree< Value >::left_most(), exsample::binary_tree< Value >::put(), exsample::binary_tree< Value >::right_most(), exsample::binary_tree< Value >::select(), exsample::binary_tree< Value >::split(), and exsample::binary_tree< Value >::tree_accumulate().
|
inlineprivate |
return the left child of this node
Definition at line 848 of file binary_tree.h.
References exsample::binary_tree< Value >::children_.
Referenced by exsample::binary_tree< Value >::accumulate(), exsample::binary_tree< Value >::cascade(), exsample::binary_tree< Value >::clear(), exsample::binary_tree< Value >::do_subtree_hash(), exsample::binary_tree< Value >::left_most(), exsample::binary_tree< Value >::select(), and exsample::binary_tree< Value >::tree_accumulate().
|
inlineprivate |
return the left child of this node
Definition at line 851 of file binary_tree.h.
References exsample::binary_tree< Value >::children_.
|
inlineprivate |
return the left-most leaf
Definition at line 405 of file binary_tree.h.
References exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::left_child(), and exsample::binary_tree< Value >::left_most().
Referenced by exsample::binary_tree< Value >::begin(), exsample::binary_tree< Value >::global_begin(), and exsample::binary_tree< Value >::left_most().
|
inlineprivate |
return the left-most leaf
Definition at line 417 of file binary_tree.h.
References exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::left_child(), and exsample::binary_tree< Value >::left_most().
|
inlineprivate |
get the left neighbour
Definition at line 399 of file binary_tree.h.
References exsample::binary_tree< Value >::neighbours_.
|
inlineprivate |
set the left neighbour
Definition at line 393 of file binary_tree.h.
References exsample::binary_tree< Value >::neighbours_.
Referenced by exsample::binary_tree< Value >::iterator::operator--(), and exsample::binary_tree< Value >::const_iterator::operator--().
|
inline |
binary_tree has a strict ownership; on copying binary trees ownership is transferred
Definition at line 71 of file binary_tree.h.
References exsample::binary_tree< Value >::children_, exsample::binary_tree< Value >::neighbours_, exsample::binary_tree< Value >::parent_, exsample::binary_tree< Value >::root(), and exsample::binary_tree< Value >::value_.
|
inlineprivate |
return the parent of this node
Definition at line 842 of file binary_tree.h.
References exsample::binary_tree< Value >::parent_.
Referenced by exsample::binary_tree< Value >::global_begin(), exsample::binary_tree< Value >::global_end(), and exsample::binary_tree< Value >::ostream_visitor< OStream >::visit().
|
inlineprivate |
return the parent of this node
Definition at line 845 of file binary_tree.h.
References exsample::binary_tree< Value >::parent_.
|
inline |
put to ostream
Definition at line 765 of file binary_tree.h.
References exsample::binary_tree< Value >::cascade(), exsample::binary_tree< Value >::empty(), exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::root(), exsample::ostream_traits< OStream >::separator(), and exsample::binary_tree< Value >::value().
Referenced by exsample::binary_tree< Value >::ostream_visitor< OStream >::visit().
|
inlineprivate |
return the right child of this node
Definition at line 854 of file binary_tree.h.
References exsample::binary_tree< Value >::children_.
Referenced by exsample::binary_tree< Value >::accumulate(), exsample::binary_tree< Value >::cascade(), exsample::binary_tree< Value >::clear(), exsample::binary_tree< Value >::do_subtree_hash(), exsample::binary_tree< Value >::right_most(), exsample::binary_tree< Value >::select(), and exsample::binary_tree< Value >::tree_accumulate().
|
inlineprivate |
return the right child of this node
Definition at line 857 of file binary_tree.h.
References exsample::binary_tree< Value >::children_.
|
inlineprivate |
return the right-most leaf
Definition at line 411 of file binary_tree.h.
References exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::right_child(), and exsample::binary_tree< Value >::right_most().
Referenced by exsample::binary_tree< Value >::end(), exsample::binary_tree< Value >::global_end(), and exsample::binary_tree< Value >::right_most().
|
inlineprivate |
return the right-most leaf
Definition at line 423 of file binary_tree.h.
References exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::right_child(), and exsample::binary_tree< Value >::right_most().
|
inlineprivate |
get the right neighbour
Definition at line 402 of file binary_tree.h.
References exsample::binary_tree< Value >::neighbours_.
|
inlineprivate |
set the right neighbour
Definition at line 396 of file binary_tree.h.
References exsample::binary_tree< Value >::neighbours_.
Referenced by exsample::binary_tree< Value >::iterator::operator++(), and exsample::binary_tree< Value >::const_iterator::operator++().
|
inline |
return true, if this is the root node
Definition at line 644 of file binary_tree.h.
References exsample::binary_tree< Value >::parent_.
Referenced by exsample::binary_tree< Value >::binary_tree(), exsample::binary_tree< Value >::empty(), exsample::binary_tree< Value >::generate(), exsample::binary_tree< Value >::global_begin(), exsample::binary_tree< Value >::global_end(), exsample::binary_tree< Value >::operator=(), and exsample::binary_tree< Value >::put().
|
inline |
select using a selector
Definition at line 486 of file binary_tree.h.
References exsample::binary_tree< Value >::global_end(), exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::left_child(), exsample::binary_tree< Value >::right_child(), exsample::binary_tree< Value >::select(), and exsample::binary_tree< Value >::value().
Referenced by exsample::binary_tree< Value >::select().
|
inline |
split this node
Definition at line 454 of file binary_tree.h.
References exsample::binary_tree< Value >::binary_tree(), exsample::binary_tree< Value >::children_, exsample::binary_tree< Value >::leaf(), and exsample::binary_tree< Value >::neighbours_.
Referenced by exsample::binary_tree< Value >::generate().
|
inline |
generate a hash value for the sub-tree selected by the given selector object
Definition at line 516 of file binary_tree.h.
|
inline |
accumulate values using a binary function and accessor object, storing intermediate values in nodes
Definition at line 567 of file binary_tree.h.
References exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::left_child(), exsample::binary_tree< Value >::right_child(), exsample::binary_tree< Value >::tree_accumulate(), and exsample::binary_tree< Value >::value().
Referenced by exsample::binary_tree< Value >::tree_accumulate().
|
inline |
accumulate values only from branches matching a Selector
Definition at line 585 of file binary_tree.h.
References exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::left_child(), exsample::binary_tree< Value >::right_child(), exsample::binary_tree< Value >::tree_accumulate(), and exsample::binary_tree< Value >::value().
|
inline |
return the value held by this node
Definition at line 638 of file binary_tree.h.
References exsample::binary_tree< Value >::value_.
Referenced by exsample::binary_tree< Value >::accumulate(), exsample::binary_tree< Value >::cascade(), exsample::binary_tree< Value >::do_subtree_hash(), exsample::binary_tree< Value >::generate(), exsample::binary_tree< Value >::get(), exsample::binary_tree< Value >::iterator::operator*(), exsample::binary_tree< Value >::const_iterator::operator*(), exsample::binary_tree< Value >::put(), exsample::binary_tree< Value >::select(), and exsample::binary_tree< Value >::tree_accumulate().
|
inline |
return the value held by this node
Definition at line 641 of file binary_tree.h.
References exsample::binary_tree< Value >::value_.
|
private |
the children of this node
Definition at line 871 of file binary_tree.h.
Referenced by exsample::binary_tree< Value >::binary_tree(), exsample::binary_tree< Value >::clear(), exsample::binary_tree< Value >::leaf(), exsample::binary_tree< Value >::left_child(), exsample::binary_tree< Value >::operator=(), exsample::binary_tree< Value >::right_child(), and exsample::binary_tree< Value >::split().
|
private |
the left and right neighbours of this node
Definition at line 429 of file binary_tree.h.
Referenced by exsample::binary_tree< Value >::binary_tree(), exsample::binary_tree< Value >::clear(), exsample::binary_tree< Value >::left_neighbour(), exsample::binary_tree< Value >::operator=(), exsample::binary_tree< Value >::right_neighbour(), and exsample::binary_tree< Value >::split().
|
private |
the parent of this node
Definition at line 864 of file binary_tree.h.
Referenced by exsample::binary_tree< Value >::binary_tree(), exsample::binary_tree< Value >::clear(), exsample::binary_tree< Value >::operator=(), exsample::binary_tree< Value >::parent(), and exsample::binary_tree< Value >::root().
|
private |
the cell held by this node
Definition at line 867 of file binary_tree.h.
Referenced by exsample::binary_tree< Value >::binary_tree(), exsample::binary_tree< Value >::clear(), exsample::binary_tree< Value >::empty(), exsample::binary_tree< Value >::generate(), exsample::binary_tree< Value >::get(), exsample::binary_tree< Value >::operator=(), and exsample::binary_tree< Value >::value().