permuter.h
来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C头文件 代码 · 共 35 行
H
35 行
#ifndef _PERMUTER_H
#define _PERMUTER_H
#include "tvector.h"
#include "prompt.h"
// iterating class for generating permutations one at a time
// each call of Current() returns the "next"
// permutation in lexicographic order, i.e.,
// if "abcde" is initial list, then "abced" is next
// after "edcba" we have "abcde".
//
// HasMore returns true when the original list is generated
// again (all n! permutations will have been generated)
class Permuter
{
public:
Permuter(const tvector<int>& list);
void Init();
bool HasMore();
void Next();
void Current(tvector<int>& list);
private:
tvector<int> myList; // current permutation
tvector<int> myOriginal; // copy of original list
bool myFirst; // first permutation?
void Swap(int x1, int x2);
void Reverse(int first, int last);
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?