bitsubsetgray.h

来自「the FXT library: fast transforms and low」· C头文件 代码 · 共 40 行

H
40
字号
#if !defined HAVE_BITSUBSETGRAY_H__#define      HAVE_BITSUBSETGRAY_H__#include "bits/graycode.h"#include "fxttypes.h"class bit_subset_gray// generate all all subsets of bits of  a given word// in minimal-change (Gray code) order.//// e.g. for the word ('.' printed for unset bits)//   ...11.1.// these words are produced by subsequent next()-calls://   ......1.//   ....1...//   ....1.1.  *** NOT a Gray code in geenral ***//   ...11...//   ...11.1.//   ...1....//   ...1..1.//   ........//{public:    ulong u_, v_;public:    bit_subset_gray(ulong v) : u_(0), v_(v)  { ; }    ~bit_subset_gray() { ; }    ulong current()  const { return u_; }    ulong out(ulong x)  { return gray_code(x) & v_; }    ulong next()  { u_ = (u_ - v_) & v_;  return out(u_); }    ulong prev()  { u_ = (u_ - 1 ) & v_;  return out(u_); }};// -------------------------#endif  // !defined HAVE_BITSUBSETGRAY_H__

⌨️ 快捷键说明

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