Logo ROOT   6.14/05
Reference Guide
Pattern.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstddef> // for size_t
4 #include <vector>
5 
6 
7 class Pattern
8 {
9  public:
10 
11  typedef typename std::vector<double>::iterator iterator;
12  typedef typename std::vector<double>::const_iterator const_iterator;
13 
15  : m_weight (0)
16  {
17  }
18 
20  {
21  }
22 
23  Pattern (const Pattern& other)
24  {
25  m_input.assign (std::begin (other.m_input), std::end (other.m_input));
26  m_output.assign (std::begin (other.m_output), std::end (other.m_output));
27  m_weight = other.m_weight;
28  }
29 
30  Pattern (Pattern&& other)
31  {
32  m_input = std::move (other.m_input);
33  m_output = std::move (other.m_output);
34  m_weight = other.m_weight;
35  }
36 
37  Pattern& operator= (const Pattern& other)
38  {
39  m_input.assign (std::begin (other.input ()), std::end (other.input ()));
40  m_output.assign (std::begin (other.output ()), std::end (other.output ()));
41  m_weight = other.m_weight;
42  return *this;
43  }
44 
45  template <typename ItValue>
46  Pattern (ItValue inputBegin, ItValue inputEnd, ItValue outputBegin, ItValue outputEnd, double _weight = 1.0)
47  : m_input (inputBegin, inputEnd)
48  , m_output (outputBegin, outputEnd)
49  , m_weight (_weight)
50  {
51  }
52 
53  template <typename ItValue>
54  Pattern (ItValue inputBegin, ItValue inputEnd, double outputValue, double _weight = 1.0)
55  : m_input (inputBegin, inputEnd)
56  , m_weight (_weight)
57  {
58  m_output.push_back (outputValue);
59  }
60 
61  template <typename InputContainer, typename OutputContainer>
62  Pattern (InputContainer& _input, OutputContainer& _output, double _weight = 1.0)
63  : m_input (std::begin (_input), std::end (_input))
64  , m_output (std::begin (_output), std::end (_output))
65  , m_weight (_weight)
66  {
67  }
68 
69  const_iterator beginInput () const { return m_input.begin (); }
70  const_iterator endInput () const { return m_input.end (); }
71  const_iterator beginOutput () const { return m_output.begin (); }
72  const_iterator endOutput () const { return m_output.end (); }
73 
74  double weight () const { return m_weight; }
75  void weight (double w) { m_weight = w; }
76 
77  size_t inputSize () const { return m_input.size (); }
78  size_t outputSize () const { return m_output.size (); }
79 
80  void addInput (double value) { m_input.push_back (value); }
81  void addOutput (double value) { m_output.push_back (value); }
82 
83  std::vector<double>& input () { return m_input; }
84  std::vector<double>& output () { return m_output; }
85  const std::vector<double>& input () const { return m_input; }
86  const std::vector<double>& output () const { return m_output; }
87 
88  private:
89  std::vector<double> m_input;
90  std::vector<double> m_output;
91  double m_weight;
92 };
const std::vector< double > & output() const
Definition: Pattern.h:86
Pattern(Pattern &&other)
Definition: Pattern.h:30
Pattern()
Definition: Pattern.h:14
const_iterator endInput() const
Definition: Pattern.h:70
std::vector< double >::iterator iterator
Definition: Pattern.h:11
Pattern(ItValue inputBegin, ItValue inputEnd, double outputValue, double _weight=1.0)
Definition: Pattern.h:54
std::vector< double > & output()
Definition: Pattern.h:84
Definition: Pattern.h:7
STL namespace.
const_iterator endOutput() const
Definition: Pattern.h:72
void weight(double w)
Definition: Pattern.h:75
Pattern(const Pattern &other)
Definition: Pattern.h:23
Pattern(ItValue inputBegin, ItValue inputEnd, ItValue outputBegin, ItValue outputEnd, double _weight=1.0)
Definition: Pattern.h:46
double m_weight
Definition: Pattern.h:91
const_iterator beginOutput() const
Definition: Pattern.h:71
size_t inputSize() const
Definition: Pattern.h:77
std::vector< double >::const_iterator const_iterator
Definition: Pattern.h:12
double weight() const
Definition: Pattern.h:74
Pattern(InputContainer &_input, OutputContainer &_output, double _weight=1.0)
Definition: Pattern.h:62
std::vector< double > m_input
Definition: Pattern.h:89
Pattern & operator=(const Pattern &other)
Definition: Pattern.h:37
std::vector< double > m_output
Definition: Pattern.h:90
~Pattern()
Definition: Pattern.h:19
std::vector< double > & input()
Definition: Pattern.h:83
size_t outputSize() const
Definition: Pattern.h:78
void addInput(double value)
Definition: Pattern.h:80
const_iterator beginInput() const
Definition: Pattern.h:69
void addOutput(double value)
Definition: Pattern.h:81
const std::vector< double > & input() const
Definition: Pattern.h:85