ant
A2 ant: class-based analysis framework
ant::Tree< T > Class Template Reference

#include <Tree.h>

+ Collaboration diagram for ant::Tree< T >:

Public Types

using node_t = snode_t< T >
 
using type = T
 

Public Member Functions

bool IsRoot () const
 
bool IsLeaf () const
 
T & operator* ()
 
const T & operator* () const
 
T & Get ()
 
const T & Get () const
 
node_t GetParent () const
 
node_t Self () const
 
const snodelist_tDaughters () const
 
void Unlink ()
 Unlink remove this node from parent. More...
 
template<typename ... args_t>
node_tCreateDaughter (args_t &&... args)
 
node_tAddDaughter (const node_t &n)
 
void SetParent (const node_t &p)
 
template<typename F >
void Map (F function) const
 
template<typename F >
void Map_level (F function, size_t level=0) const
 
template<typename F >
void Map_nodes (F function) const
 Map_nodes runs through the tree recursively depth-first. More...
 
size_t Size () const
 
size_t Depth () const
 
void Sort ()
 
template<typename Compare >
void Sort (Compare comp)
 
template<typename U , typename Compare >
bool IsEqual (const snode_t< U > &other, Compare comp) const
 
template<typename U >
bool IsEqual (const snode_t< U > &other) const
 
template<typename U = T, typename Transform = std::function<U(const node_t&)>>
snode_t< U > DeepCopy (Transform transform) const
 DeepCopy uses the given transfrom from node_t to U to deeply copy the tree. More...
 
template<typename U = T>
snode_t< U > DeepCopy () const
 
void GetUniquePermutations (std::vector< node_t > &leaves, std::vector< std::vector< int >> &perms, int &i_leave_offset) const
 GetUniquePermutations calculates the unique permutations of the leaves. More...
 

Static Public Member Functions

template<typename ... args_t>
static node_t MakeNode (args_t &&... args)
 
template<typename Head , typename... Daughters>
static node_t Make (Head &&head, const std::tuple< Daughters... > &daughters)
 

Protected Types

using wnode_t = std::weak_ptr< Tree >
 
using snodelist_t = std::list< node_t >
 

Protected Member Functions

void RemoveDaughter (Tree *t)
 
 Tree (T &&data_)
 
 Tree ()
 
template<class Archive >
void serialize (Archive &archive)
 

Static Protected Member Functions

template<typename Daughter , typename... Daughters>
static std::enable_if< std_ext::first_element_is_tuple< Daughters... >::value, void >::type make_impl (node_t &head, const std::tuple< Daughter, Daughters... > &daughters)
 
template<typename Daughter , typename... Daughters>
static std::enable_if<!std_ext::first_element_is_tuple< Daughters... >::value, void >::type make_impl (node_t &head, const std::tuple< Daughter, Daughters... > &daughters)
 
template<typename Daughter = void>
static void make_impl (node_t &, const std::tuple<> &)
 
template<typename Item >
static std::enable_if< std::is_convertible< Item, T >::value, node_t & >::type make_impl (node_t &head, Item &&item)
 
template<typename Item >
static std::enable_if< std::is_convertible< Item, node_t >::value, node_t & >::type make_impl (node_t &head, Item &&item)
 

Protected Attributes

data
 
wnode_t parent
 
wnode_t self
 
snodelist_t daughters
 
bool is_sorted
 

Friends

template<typename >
class Tree
 
class cereal::access
 

Member Typedef Documentation

◆ node_t

template<typename T>
using ant::Tree< T >::node_t = snode_t<T>

◆ snodelist_t

template<typename T>
using ant::Tree< T >::snodelist_t = std::list<node_t>
protected

◆ type

template<typename T>
using ant::Tree< T >::type = T

◆ wnode_t

template<typename T>
using ant::Tree< T >::wnode_t = std::weak_ptr<Tree>
protected

Constructor & Destructor Documentation

◆ Tree() [1/2]

template<typename T>
ant::Tree< T >::Tree ( T &&  data_)
inlineprotected

◆ Tree() [2/2]

template<typename T>
ant::Tree< T >::Tree ( )
inlineprotected

Member Function Documentation

◆ AddDaughter()

template<typename T>
node_t& ant::Tree< T >::AddDaughter ( const node_t n)
inline

◆ CreateDaughter()

template<typename T>
template<typename ... args_t>
node_t& ant::Tree< T >::CreateDaughter ( args_t &&...  args)
inline

◆ Daughters()

template<typename T>
const snodelist_t& ant::Tree< T >::Daughters ( ) const
inline

◆ DeepCopy() [1/2]

template<typename T>
template<typename U = T, typename Transform = std::function<U(const node_t&)>>
snode_t<U> ant::Tree< T >::DeepCopy ( Transform  transform) const
inline

DeepCopy uses the given transfrom from node_t to U to deeply copy the tree.

Parameters
transformfunction to convert node to new type U

◆ DeepCopy() [2/2]

template<typename T>
template<typename U = T>
snode_t<U> ant::Tree< T >::DeepCopy ( ) const
inline

◆ Depth()

template<typename T>
size_t ant::Tree< T >::Depth ( ) const
inline

◆ Get() [1/2]

template<typename T>
T& ant::Tree< T >::Get ( )
inline

◆ Get() [2/2]

template<typename T>
const T& ant::Tree< T >::Get ( ) const
inline

◆ GetParent()

template<typename T>
node_t ant::Tree< T >::GetParent ( ) const
inline

◆ GetUniquePermutations()

template<typename T>
void ant::Tree< T >::GetUniquePermutations ( std::vector< node_t > &  leaves,
std::vector< std::vector< int >> &  perms,
int &  i_leave_offset 
) const
inline

GetUniquePermutations calculates the unique permutations of the leaves.

Parameters
leavesthe leaves of the tree for convenience, defines also the order of indices in perms
permspermutations as indices corresponding to vector leaves (offseted by possible i_leave_offset). Use indices to assign particles to leaves (not leaves to particles) i_leave_offset separates the trivial equivalence classes from the actually permuted leaves
Note
We assume that the tree is already sorted with std::less comparison, anything else will lead to wrong results.

◆ IsEqual() [1/2]

template<typename T>
template<typename U , typename Compare >
bool ant::Tree< T >::IsEqual ( const snode_t< U > &  other,
Compare  comp 
) const
inline

◆ IsEqual() [2/2]

template<typename T>
template<typename U >
bool ant::Tree< T >::IsEqual ( const snode_t< U > &  other) const
inline

◆ IsLeaf()

template<typename T>
bool ant::Tree< T >::IsLeaf ( ) const
inline

◆ IsRoot()

template<typename T>
bool ant::Tree< T >::IsRoot ( ) const
inline

◆ Make()

template<typename T>
template<typename Head , typename... Daughters>
static node_t ant::Tree< T >::Make ( Head &&  head,
const std::tuple< Daughters... > &  daughters 
)
inlinestatic

◆ make_impl() [1/5]

template<typename T>
template<typename Daughter , typename... Daughters>
static std::enable_if<std_ext::first_element_is_tuple<Daughters...>::value, void>::type ant::Tree< T >::make_impl ( node_t head,
const std::tuple< Daughter, Daughters... > &  daughters 
)
inlinestaticprotected

◆ make_impl() [2/5]

template<typename T>
template<typename Daughter , typename... Daughters>
static std::enable_if<!std_ext::first_element_is_tuple<Daughters...>::value, void>::type ant::Tree< T >::make_impl ( node_t head,
const std::tuple< Daughter, Daughters... > &  daughters 
)
inlinestaticprotected

◆ make_impl() [3/5]

template<typename T>
template<typename Daughter = void>
static void ant::Tree< T >::make_impl ( node_t ,
const std::tuple<> &   
)
inlinestaticprotected

◆ make_impl() [4/5]

template<typename T>
template<typename Item >
static std::enable_if<std::is_convertible<Item, T>::value, node_t&>::type ant::Tree< T >::make_impl ( node_t head,
Item &&  item 
)
inlinestaticprotected

◆ make_impl() [5/5]

template<typename T>
template<typename Item >
static std::enable_if<std::is_convertible<Item, node_t>::value, node_t&>::type ant::Tree< T >::make_impl ( node_t head,
Item &&  item 
)
inlinestaticprotected

◆ MakeNode()

template<typename T>
template<typename ... args_t>
static node_t ant::Tree< T >::MakeNode ( args_t &&...  args)
inlinestatic

◆ Map()

template<typename T>
template<typename F >
void ant::Tree< T >::Map ( function) const
inline

◆ Map_level()

template<typename T>
template<typename F >
void ant::Tree< T >::Map_level ( function,
size_t  level = 0 
) const
inline

◆ Map_nodes()

template<typename T>
template<typename F >
void ant::Tree< T >::Map_nodes ( function) const
inline

Map_nodes runs through the tree recursively depth-first.

Parameters
functionapplied to each node
Note
depth first is important for GetUniquePermutations

◆ operator*() [1/2]

template<typename T>
T& ant::Tree< T >::operator* ( )
inline

◆ operator*() [2/2]

template<typename T>
const T& ant::Tree< T >::operator* ( ) const
inline

◆ RemoveDaughter()

template<typename T>
void ant::Tree< T >::RemoveDaughter ( Tree< T > *  t)
inlineprotected

◆ Self()

template<typename T>
node_t ant::Tree< T >::Self ( ) const
inline

◆ serialize()

template<typename T>
template<class Archive >
void ant::Tree< T >::serialize ( Archive &  archive)
inlineprotected

◆ SetParent()

template<typename T>
void ant::Tree< T >::SetParent ( const node_t p)
inline

◆ Size()

template<typename T>
size_t ant::Tree< T >::Size ( ) const
inline

◆ Sort() [1/2]

template<typename T>
void ant::Tree< T >::Sort ( )
inline

◆ Sort() [2/2]

template<typename T>
template<typename Compare >
void ant::Tree< T >::Sort ( Compare  comp)
inline

◆ Unlink()

template<typename T>
void ant::Tree< T >::Unlink ( )
inline

Unlink remove this node from parent.

Note
ensure that the instance of the node is local, and NOT some referenced node in the original tree

Friends And Related Function Documentation

◆ cereal::access

template<typename T>
friend class cereal::access
friend

◆ Tree

template<typename T>
template<typename >
friend class Tree
friend

Member Data Documentation

◆ data

template<typename T>
T ant::Tree< T >::data
protected

◆ daughters

template<typename T>
snodelist_t ant::Tree< T >::daughters
protected

◆ is_sorted

template<typename T>
bool ant::Tree< T >::is_sorted
protected

◆ parent

template<typename T>
wnode_t ant::Tree< T >::parent
protected

◆ self

template<typename T>
wnode_t ant::Tree< T >::self
protected

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