blob: 279c3ade41844a357a3004ad366939f19f16a1ca (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
/**
* @author Peter Boros
* @date 2004/08/20
* @version $Id$
* @file permuter.h
* @brief Permuter class.
*/
#pragma once
#include <vector>
#include <map>
#include <string>
namespace fsa {
// {{{ class Permuter
/**
* @class Permuter
* @brief Permuter class.
*/
class Permuter {
private:
static const unsigned int MAX_UNIT_LENGTH = 6;
using PermTab = std::vector<std::string>;
using PermTabIterator = std::vector<std::string>::iterator;
using PermMap = std::map<std::string,unsigned int>;
using PermMapIterator = std::map<std::string,unsigned int>::iterator;
using PermMapConstIterator = std::map<std::string,unsigned int>::const_iterator;
PermTab _permtab;
PermMap _permmap;
unsigned int _size;
std::string _seed;
void initRec(const std::string &input, std::string tail);
public:
/**
* @brief Default constructor.
*/
Permuter();
/**
* @brief Destructor.
*/
~Permuter();
std::string getPerm(unsigned int id) const { return _permtab[id]; }
int getPermId(const std::string &perm) const;
static unsigned int firstComb(unsigned int n, unsigned int m);
static unsigned int nextComb(unsigned int c, unsigned int m);
};
// }}}
} // namespace fsa
|