Logo ROOT   6.08/07
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 
14 
16  : m_weight (0)
17  {
18  }
19 
21  {
22  }
23 
24  Pattern (const Pattern& other)
25  {
26  m_input.assign (std::begin (other.m_input), std::end (other.m_input));
27  m_output.assign (std::begin (other.m_output), std::end (other.m_output));
28  m_weight = other.m_weight;
29  }
30 
31  Pattern (Pattern&& other)
32  {
33  m_input = std::move (other.m_input);
34  m_output = std::move (other.m_output);
35  m_weight = other.m_weight;
36  }
37 
38 
39  Pattern& operator= (const Pattern& other)
40  {
41  m_input.assign (std::begin (other.input ()), std::end (other.input ()));
42  m_output.assign (std::begin (other.output ()), std::end (other.output ()));
43  m_weight = other.m_weight;
44  return *this;
45  }
46 
47 
48  template <typename ItValue>
49  Pattern (ItValue inputBegin, ItValue inputEnd, ItValue outputBegin, ItValue outputEnd, double _weight = 1.0)
50  : m_input (inputBegin, inputEnd)
51  , m_output (outputBegin, outputEnd)
52  , m_weight (_weight)
53  {
54  }
55 
56  template <typename ItValue>
57  Pattern (ItValue inputBegin, ItValue inputEnd, double outputValue, double _weight = 1.0)
58  : m_input (inputBegin, inputEnd)
59  , m_weight (_weight)
60  {
61  m_output.push_back (outputValue);
62  }
63 
64 
65 
66  template <typename InputContainer, typename OutputContainer>
67  Pattern (InputContainer& _input, OutputContainer& _output, double _weight = 1.0)
68  : m_input (std::begin (_input), std::end (_input))
69  , m_output (std::begin (_output), std::end (_output))
70  , m_weight (_weight)
71  {
72  }
73 
74 
75  const_iterator beginInput () const { return m_input.begin (); }
76  const_iterator endInput () const { return m_input.end (); }
77  const_iterator beginOutput () const { return m_output.begin (); }
78  const_iterator endOutput () const { return m_output.end (); }
79 
80  double weight () const { return m_weight; }
81  void weight (double w) { m_weight = w; }
82 
83  size_t inputSize () const { return m_input.size (); }
84  size_t outputSize () const { return m_output.size (); }
85 
86  void addInput (double value) { m_input.push_back (value); }
87  void addOutput (double value) { m_output.push_back (value); }
88 
89  std::vector<double>& input () { return m_input; }
90  std::vector<double>& output () { return m_output; }
91  const std::vector<double>& input () const { return m_input; }
92  const std::vector<double>& output () const { return m_output; }
93 
94  private:
95  std::vector<double> m_input;
96  std::vector<double> m_output;
97  double m_weight;
98 };
99 
100 
101 
102 
const std::vector< double > & output() const
Definition: Pattern.h:92
Pattern(Pattern &&other)
Definition: Pattern.h:31
Pattern()
Definition: Pattern.h:15
const_iterator endInput() const
Definition: Pattern.h:76
std::vector< double >::iterator iterator
Definition: Pattern.h:11
Pattern(ItValue inputBegin, ItValue inputEnd, double outputValue, double _weight=1.0)
Definition: Pattern.h:57
std::vector< double > & output()
Definition: Pattern.h:90
Definition: Pattern.h:7
STL namespace.
const_iterator endOutput() const
Definition: Pattern.h:78
void weight(double w)
Definition: Pattern.h:81
Pattern(const Pattern &other)
Definition: Pattern.h:24
Pattern(ItValue inputBegin, ItValue inputEnd, ItValue outputBegin, ItValue outputEnd, double _weight=1.0)
Definition: Pattern.h:49
double m_weight
Definition: Pattern.h:97
const_iterator beginOutput() const
Definition: Pattern.h:77
size_t inputSize() const
Definition: Pattern.h:83
std::vector< double >::const_iterator const_iterator
Definition: Pattern.h:12
double weight() const
Definition: Pattern.h:80
Pattern(InputContainer &_input, OutputContainer &_output, double _weight=1.0)
Definition: Pattern.h:67
std::vector< double > m_input
Definition: Pattern.h:95
Pattern & operator=(const Pattern &other)
Definition: Pattern.h:39
std::vector< double > m_output
Definition: Pattern.h:96
~Pattern()
Definition: Pattern.h:20
std::vector< double > & input()
Definition: Pattern.h:89
size_t outputSize() const
Definition: Pattern.h:84
void addInput(double value)
Definition: Pattern.h:86
const_iterator beginInput() const
Definition: Pattern.h:75
void addOutput(double value)
Definition: Pattern.h:87
const std::vector< double > & input() const
Definition: Pattern.h:91