libbf  0.1
 All Classes Functions Typedefs Friends Pages
counter_vector.h
1 #ifndef BF_COUNTER_VECTOR_H
2 #define BF_COUNTER_VECTOR_H
3 
4 #include <cstdint>
5 #include <vector>
6 #include <bf/bitvector.h>
7 
8 namespace bf {
9 
13 {
14  friend std::string to_string(counter_vector const&, bool, size_t);
15 
16 public:
25  counter_vector(size_t cells, size_t width);
26 
36  bool increment(size_t cell, size_t value = 1);
37 
44  bool decrement(size_t cell, size_t value = 1);
45 
51  size_t count(size_t cell) const;
52 
56  void set(size_t cell, size_t value);
57 
59  void clear();
60 
63  size_t size() const;
64 
67  size_t max() const;
68 
71  size_t width() const;
72 
73 private:
74  bitvector bits_;
75  size_t width_;
76 };
77 
80 std::string to_string(counter_vector const& v, bool all = false,
81  size_t cut_off = 0);
82 
83 } // namespace bf
84 
85 #endif