vdj_pipe
pipeline for processing DNA sequence data
histogram_1d.hpp
Go to the documentation of this file.
1 
7 #ifndef HISTOGRAM_1D_HPP_
8 #define HISTOGRAM_1D_HPP_
9 #include <vector>
10 #include <iosfwd>
11 #include <ostream>
12 
13 namespace vdj_pipe{
14 
17 class Histogram_1d {
18 public:
19 
20  void add(const unsigned val) {
21  if( v_.size() <= val ) v_.resize(val + 1, 0);
22  ++v_[val];
23  }
24 
25  std::ostream& print(std::ostream& os, const char delim) const {
26  for(std::size_t n = 0; n != v_.size(); ++n) {
27  os << n << delim << v_[n] << '\n';
28  }
29  return os;
30  }
31 
32 private:
33  std::vector<unsigned> v_;
34 };
35 
36 }//namespace vdj_pipe
37 #endif /* HISTOGRAM_1D_HPP_ */
void add(const unsigned val)
Definition: histogram_1d.hpp:20
std::ostream & print(std::ostream &os, const char delim) const
Definition: histogram_1d.hpp:25
Main namespace of vdj_pipe library.
Definition: keywords_variable.hpp:11
std::vector< unsigned > v_
Definition: histogram_1d.hpp:33
const std::size_t n
Definition: vector_set_test.cpp:26
simple unsigned integer-based histogram
Definition: histogram_1d.hpp:17