-
Notifications
You must be signed in to change notification settings - Fork 5
/
ResultSet.h
48 lines (36 loc) · 1.17 KB
/
ResultSet.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
// Dynamic result set class
// Originally by Gonzalo Navarro
#ifndef _RESULTSET_H_
#define _RESULTSET_H_
#ifndef ulong
typedef unsigned long ulong;
#endif
class ResultSet {
private:
ulong n, lgn;
ulong *tree;
ulong lg(ulong);
ulong conv (ulong p, ulong n, ulong lgn);
ulong unconv (ulong p, ulong n, ulong lgn);
ulong clearRangeLeft (ulong p1, ulong n, ulong pos, ulong pot);
ulong clearRangeRight (ulong p2, ulong n, ulong pos, ulong pot);
ulong clearBoth (ulong n, ulong p1, ulong p2, ulong pos, ulong pot);
ulong nextSmallest (ulong n, ulong pos, ulong pot);
ulong nextLarger (ulong n, ulong p, ulong pos, ulong pot);
void prnspace (ulong k);
public:
// creates empty results data structure for n nodes numbered 0..n-1
ResultSet(ulong n);
~ResultSet();
// returns 0/1 telling whether result p is not/is present in R
bool get(ulong p);
// inserts result p into R
void set(ulong p);
// clears all results p1..p2 in R
void clearRange (ulong p1, ulong p2);
// clears all results
void clear();
// returns pos of next(p) in R, or -1 if none
ulong nextResult (ulong p);
};
#endif // _RESULTSET_H_