sizes.h

来自「Linux下一个可以比较二进制文件的工具xdelta3.0u的源码。」· C头文件 代码 · 共 70 行

H
70
字号
// -*- Mode: C++ -*-namespace regtest {template <typename T, typename U>class SizeIterator { public:  SizeIterator(MTRandom *rand, size_t howmany)    : rand_(rand),      count_(0),      fixed_(U::sizes),      fixed_size_(SIZEOF_ARRAY(U::sizes)),      howmany_(howmany) { }  T Get() {    if (count_ < fixed_size_) {      return fixed_[count_];    }    return rand_->Rand<T>() % U::max_value;  }  bool Done() {    return count_ >= fixed_size_ && count_ >= howmany_;  }  void Next() {    count_++;  } private:  MTRandom *rand_;  size_t count_;  T* fixed_;  size_t fixed_size_;  size_t howmany_;};class SmallSizes {public:  static size_t sizes[];  static size_t max_value;};size_t SmallSizes::sizes[] = {  0, 1, Constants::BLOCK_SIZE / 4, 3333,   Constants::BLOCK_SIZE - (Constants::BLOCK_SIZE / 3),  Constants::BLOCK_SIZE,  Constants::BLOCK_SIZE + (Constants::BLOCK_SIZE / 3),  2 * Constants::BLOCK_SIZE - (Constants::BLOCK_SIZE / 3),  2 * Constants::BLOCK_SIZE,  2 * Constants::BLOCK_SIZE + (Constants::BLOCK_SIZE / 3),};size_t SmallSizes::max_value = Constants::BLOCK_SIZE * 3;class LargeSizes {public:  static size_t sizes[];  static size_t max_value;};size_t LargeSizes::sizes[] = {  1 << 20,  1 << 18,  1 << 16,};size_t LargeSizes::max_value = 1<<20;}  // namespace regtest

⌨️ 快捷键说明

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