MachineIntelligenceCore:Algorithms
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Sample.hpp
Go to the documentation of this file.
1 
23 #ifndef SRC_TYPES_SAMPLE_HPP_
24 #define SRC_TYPES_SAMPLE_HPP_
25 
26 #include <memory>
27 
28 namespace mic {
29 namespace types {
30 
37 template<typename DataType, typename LabelType>
38 class Sample {
39 public:
40 
44  Sample() : sample_data(nullptr), sample_label(nullptr), sample_index(-1) { }
45 
52  Sample(std::shared_ptr<DataType> data_, std::shared_ptr<LabelType> label_, size_t index_= -1) : sample_data(data_), sample_label(label_), sample_index(index_) { }
53 
58  Sample(const mic::types::Sample<DataType, LabelType>& sample_) : sample_data(sample_.data()), sample_label(sample_.label()), sample_index(sample_.index()) { }
59 
66  // Copy sample data.
67  this->sample_data = sample_.sample_data;
68  this->sample_label = sample_.sample_label;
69  this->sample_index = sample_.sample_index;
70  // Return object.
71  return *this;
72  }
73 
77  virtual ~Sample() { };
78 
80  std::shared_ptr<DataType> data() const {
81  return sample_data;
82  }
83 
85  std::shared_ptr<LabelType> label() const {
86  return sample_label;
87  }
88 
90  size_t index() const {
91  return sample_index;
92  }
93 
94 private:
96  std::shared_ptr<DataType> sample_data;
97 
99  std::shared_ptr<LabelType> sample_label;
100 
102  size_t sample_index;
103 };
104 
105 
106 } /* namespace types */
107 } /* namespace mic */
108 
109 #endif /* SRC_TYPES_SAMPLE_HPP_ */
size_t sample_index
The sample index (the sample "position" in original dataset).
Definition: Sample.hpp:102
size_t index() const
Returns the sample number (the sample "position" in original dataset).
Definition: Sample.hpp:90
Template class storing the data-label pairs. Additionally it stores the the index of the sample (main...
Definition: Sample.hpp:38
Sample(const mic::types::Sample< DataType, LabelType > &sample_)
Definition: Sample.hpp:58
std::shared_ptr< LabelType > label() const
Returns the returns the sample label.
Definition: Sample.hpp:85
std::shared_ptr< LabelType > sample_label
Stores the label.
Definition: Sample.hpp:99
mic::types::Sample< DataType, LabelType > & operator=(const mic::types::Sample< DataType, LabelType > &sample_)
Definition: Sample.hpp:65
Sample(std::shared_ptr< DataType > data_, std::shared_ptr< LabelType > label_, size_t index_=-1)
Definition: Sample.hpp:52
virtual ~Sample()
Definition: Sample.hpp:77
std::shared_ptr< DataType > data() const
Returns the sample data.
Definition: Sample.hpp:80
std::shared_ptr< DataType > sample_data
Stores the data.
Definition: Sample.hpp:96