ATLAS Offline Software
Tree.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGHLTJETHYPO_TREE_H
6 #define TRIGHLTJETHYPO_TREE_H
7 
8 /*
9  * The input vector of unsigned ints is interpreted as a tree structure of
10  * conditions objects. The elements oif the input vector refer to the position
11  * of the Conditions objects is some sequence.
12  *
13  * With this structure nested conditions are supported.
14  */
15 #include <vector>
16 #include <ostream>
17 
18 class Tree{
19  public:
20  Tree(const std::vector<std::size_t>&);
21 
22  std::size_t parent(std::size_t) const;
23  std::vector<std::size_t> siblings(std::size_t) const;
24  std::size_t size() const;
25  const std::vector<std::size_t>& leaves() const;
26  bool is_leaf(size_t) const;
27 
28  // does the tree have a root node and
29  // and all other nodes are children of this node?
30  bool is_simple() const;
31  const std::vector<std::size_t>& firstGeneration() const;
32 
33  std::vector<std::size_t>::const_iterator cbegin() const {
34  return m_parents.cbegin();
35  }
36 
37 
38  std::vector<std::size_t>::const_iterator cend() const {
39  return m_parents.cend();
40  }
41 
42 
43 
44  std::size_t depth(std::size_t) const;
45 
46  private:
47  std::vector<std::size_t> m_parents;
48  std::vector<std::vector<std::size_t>> m_children;
49  std::vector<std::size_t> m_leaves;
50  std::vector<std::size_t> m_firstGeneration;
51 };
52 
53 std::ostream& operator<< (std::ostream&, const Tree&);
54 #endif
Tree::cend
std::vector< std::size_t >::const_iterator cend() const
Definition: Tree.h:38
Tree
Definition: Tree.h:18
Tree::siblings
std::vector< std::size_t > siblings(std::size_t) const
Definition: Tree.cxx:39
Tree::is_simple
bool is_simple() const
Definition: Tree.cxx:64
Tree::m_children
std::vector< std::vector< std::size_t > > m_children
Definition: Tree.h:48
Tree::m_parents
std::vector< std::size_t > m_parents
Definition: Tree.h:47
Tree::depth
std::size_t depth(std::size_t) const
Definition: Tree.cxx:75
operator<<
std::ostream & operator<<(std::ostream &, const Tree &)
Definition: Tree.cxx:84
Tree::is_leaf
bool is_leaf(size_t) const
Definition: Tree.cxx:52
Tree::parent
std::size_t parent(std::size_t) const
Definition: Tree.cxx:34
Tree::m_leaves
std::vector< std::size_t > m_leaves
Definition: Tree.h:49
Tree::firstGeneration
const std::vector< std::size_t > & firstGeneration() const
Definition: Tree.cxx:59
Tree::Tree
Tree(const std::vector< std::size_t > &)
Definition: Tree.cxx:8
Tree::size
std::size_t size() const
Definition: Tree.cxx:43
Tree::cbegin
std::vector< std::size_t >::const_iterator cbegin() const
Definition: Tree.h:33
Tree::m_firstGeneration
std::vector< std::size_t > m_firstGeneration
Definition: Tree.h:50
Tree::leaves
const std::vector< std::size_t > & leaves() const
Definition: Tree.cxx:48