Advertisement
Guest User

bit_utils.h

a guest
Oct 26th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #ifndef BIT_UTILS
  2. #define BIT_UTILS
  3.  
  4. #include <vector>
  5.  
  6.  
  7. typedef unsigned char byte;
  8.  
  9. struct bits
  10. {
  11.     std::vector<byte> b;
  12.     int size;
  13. };
  14.  
  15.  
  16. /* return the byte in position n */
  17. template<class byte_iterator>
  18. byte get_byte(byte_iterator begin, int n);
  19.  
  20. /* return n bit starting from the bit in start */
  21. template<class byte_iterator>
  22. bits get_bits(byte_iterator begin, int start, int n);
  23.  
  24. /* insert n bits in begin at start*/
  25. template<class byte_iterator>
  26. void bits_insert(const bits& b, byte_iterator begin, int start, int n);
  27.  
  28. /* return number of bits matching in the two bytes, supposed different */
  29. int bit_compare(byte a, byte b);
  30.  
  31. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement