1 #ifndef CGPERF_POSITIONS_H
2 #define CGPERF_POSITIONS_H
5 /*------------------------------------------------------------------------------------------------*/
6 #include "namespace/positions.h"
7 /*------------------------------------------------------------------------------------------------*/
9 struct PositionIterator
;
10 struct PositionReverseIterator
;
14 * Maximum key position specifiable by the user, 1-based. Note that max_key_pos-1 must fit
15 * into the element type of positions[], below.
17 POS_MAX_KEY_POS
= 255,
18 /* Denotes the last char of a keyword, depending on the keyword's length */
21 * Maximum possible size. Since duplicates are eliminated and the possible 0-based positions
22 * are -1..max_key_pos-1, this is:
24 POS_MAX_SIZE
= POS_MAX_KEY_POS
+ 1,
26 /*}}} constants -- END */
31 * array of positions. 0 for the first char, 1 for the second char etc., lastchar for the
34 s32 positions
[POS_MAX_SIZE
];
35 /* number of positions */
37 /*}}} public -- END */
39 /* The special case denoted by '*' */
41 /*}}} private -- END */
44 /*{{{ public static methods */
45 static struct Positions
*pos_new(void);
46 static struct Positions
*pos_new_cpy(struct Positions
*src
);
47 static void pos_print(struct Positions
*t
);
48 static void pos_del(struct Positions
*t
);
49 static bool pos_contains(struct Positions
*t
, s32 pos
);
50 static void pos_add(struct Positions
*t
, s32 pos
);
51 static void pos_remove(struct Positions
*t
, s32 pos
);
53 static void pos_set_useall(struct Positions
*t
, bool useall
);
54 static bool pos_sort(struct Positions
*t
);
55 static struct PositionIterator
*pos_iterator(struct Positions
*t
, s32 maxlen
);
56 static struct PositionIterator
*pos_iterator_all(struct Positions
*t
);
57 static struct PositionReverseIterator
*pos_reviterator(struct Positions
*t
);
58 static void pos_cpy(struct Positions
*d
, struct Positions
*s
);
59 /*}}} public static methods -- END */
60 /*}}} Position -- END */
61 /*{{{ PositionIterator */
64 /* end of iteration marker */
67 /*}}} constants -- END */
69 struct PositionIterator
{
71 struct Positions
*set
;
76 /*{{{ public static methods */
77 static struct PositionIterator
*positer_new(struct Positions
*positions
, s32 maxlen
);
78 static struct PositionIterator
*positer_new_all(struct Positions
*positions
);
79 static void positer_del(struct PositionIterator
*t
);
80 static u32
positer_remaining(struct PositionIterator
*t
);
81 static s32
positer_next(struct PositionIterator
*t
);
82 /*}}} public static methods -- END */
83 /*}}} PositionIterator -- END */
84 /*{{{ PositionReverseIterator */
85 /*{{{ constants and types */
87 /* end of iteration marker */
90 struct PositionReverseIterator
{
92 struct Positions
*set
;
95 /*}}} private -- END */
97 /*}}} constants and types -- END */
98 /*{{{ public static methods */
99 static struct PositionReverseIterator
*posrevit_new(struct Positions
*positions
);
100 static void posrevit_del(struct PositionReverseIterator
*t
);
101 static s32
posrevit_next(struct PositionReverseIterator
*t
);
102 /*}}} public static methods -- END */
103 /*}}} PositionReverseIterator -- END */
104 /*------------------------------------------------------------------------------------------------*/
106 #include "namespace/positions.h"
108 /*------------------------------------------------------------------------------------------------*/