BitField.hpp
Go to the documentation of this file.
1 #ifndef LVR2_ASCII_RENDERER_BITFIELD_HPP
2 #define LVR2_ASCII_RENDERER_BITFIELD_HPP
3 
4 #include <iostream>
5 
6 namespace lvr2 {
7 
8 template<unsigned int W, unsigned int H>
9 struct BitField {
10  // storage
11  unsigned char data = 0;
12 
13  BitField():data(0){}
14 
15  void set(const unsigned int& i, const unsigned int& j)
16  {
17  data |= 1UL << (i * H + j);
18  }
19 
20  bool get(const unsigned int& i, const unsigned int& j) const
21  {
22  return (data >> (i * H + j)) & 1U;
23  }
24 
25  void toggle(const unsigned int& i, const unsigned int& j)
26  {
27  data ^= 1UL << (i * H + j);
28  }
29 
30  void clear(const unsigned int& i, const unsigned int& j)
31  {
32  data &= ~(1UL << (i * H + j) );
33  }
34 
35 
36 };
37 
38 } // namespace lvr2
39 
40 #endif // LVR2_ASCII_RENDERER_BITFIELD_HPP
unsigned char data
Definition: BitField.hpp:11
void toggle(const unsigned int &i, const unsigned int &j)
Definition: BitField.hpp:25
void clear(const unsigned int &i, const unsigned int &j)
Definition: BitField.hpp:30


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:06