ATLAS Offline Software
Loading...
Searching...
No Matches
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
18class 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
53std::ostream& operator<< (std::ostream&, const Tree&);
54#endif
std::ostream & operator<<(std::ostream &, const Tree &)
Definition Tree.cxx:84
Definition Tree.h:18
std::size_t parent(std::size_t) const
Definition Tree.cxx:34
bool is_leaf(size_t) const
Definition Tree.cxx:52
std::vector< std::size_t > m_parents
Definition Tree.h:47
std::vector< std::size_t > siblings(std::size_t) const
Definition Tree.cxx:39
std::vector< std::size_t > m_firstGeneration
Definition Tree.h:50
std::vector< std::size_t >::const_iterator cbegin() const
Definition Tree.h:33
std::vector< std::vector< std::size_t > > m_children
Definition Tree.h:48
const std::vector< std::size_t > & leaves() const
Definition Tree.cxx:48
const std::vector< std::size_t > & firstGeneration() const
Definition Tree.cxx:59
std::size_t size() const
Definition Tree.cxx:43
std::vector< std::size_t > m_leaves
Definition Tree.h:49
std::vector< std::size_t >::const_iterator cend() const
Definition Tree.h:38
bool is_simple() const
Definition Tree.cxx:64
Tree(const std::vector< std::size_t > &)
Definition Tree.cxx:8
std::string depth
tag string for intendation
Definition fastadd.cxx:46