bitvect.h

来自「Thinking in C++ 2nd edition source code 」· C头文件 代码 · 共 30 行

H
30
字号
//: C07:Bitvect.h
// From Thinking in C++, 2nd Edition
// at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
// Bit Vector
#ifndef BITVECT_H_
#define BITVECT_H_

class BitVector {
  unsigned char* bytes;
  int Bits, numBytes;
public:
  BitVector(); // Default: 0 size
  // init points to an array of bytes
  // size is measured in bytes
  BitVector(unsigned char* init,
            int size = 8);
  // binary is a string of 1s and 0s
  BitVector(char* binary);
  ~BitVector();
  void set(int bit);
  void clear(int bit);
  int read(int bit);
  int bits(); // Number of bits in the vector
  void bits(int sz); // Set number of bits
  void print(const char* msg = "");
};
#endif // BITVECT_H_ ///:~

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?