-
Notifications
You must be signed in to change notification settings - Fork 13
/
combinatorial_object.h
63 lines (49 loc) · 1.88 KB
/
combinatorial_object.h
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
// Author: Ivan Kazmenko (gassa@mail.ru)
#ifndef COMBINATORIAL_OBJECT_H_
#define COMBINATORIAL_OBJECT_H_
#include <cstdint>
#include <iostream>
#include <vector>
using std::string;
using std::vector;
using std::istream;
using std::ostream;
using std::cin;
using std::cout;
class CombinatorialObject
{
public:
/// total number of objects of length n,
/// undefined if negative or overflow
virtual int64_t total (int n) = 0;
/// lexicographically sorted vector of all objects of length n
/// undefined if negative
virtual vector <vector <int> > generate_all (int n) = 0;
/// validity of given object
virtual bool is_valid (vector <int> const & v) = 0;
/// 0-based lexicographical number of given valid object,
/// undefined if overflow
virtual int64_t number_by_object (vector <int> const & v) = 0;
/// object of length n with given 0-based lexicographical number,
/// undefined if out of bounds
virtual vector <int> object_by_number (int n, int64_t k) = 0;
/// transform valid object to lexicographically previous object,
/// true if successful, false and undefined state if was first
virtual bool prev (vector <int> & v) = 0;
/// transform valid object to lexicographically next object,
/// true if successful, false and undefined state if was last
virtual bool next (vector <int> & v) = 0;
/// check integrity for objects of length n
void check (int n);
/// read n vector elements from in_stream, separated by whitespace
vector <int> input (int n, istream & in_stream = cin);
/// write space-separated vector elements and a newline to out_stream
void print (vector <int> const & v, ostream & out_stream = cout);
/// interact with in_stream and out_stream
void interact (istream & in_stream = cin, ostream & out_stream = cout);
/// name of combinatorial object
virtual string name () = 0;
/// virtual destructor
virtual ~CombinatorialObject ();
};
#endif // COMBINATORIAL_OBJECT_H_