-
Notifications
You must be signed in to change notification settings - Fork 1
/
class.h
108 lines (90 loc) · 2.08 KB
/
class.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* class.h
*
* A tree contains a set of codepoints. It is implemented as a
* binary search tree with each node containing a disjoint urange32
* struct.
*/
#ifndef __regex_class
#define __regex_class
#include <stdbool.h>
#include "hooks.h"
#include "util.h"
typedef struct _class class_t;
/** insert_codepoint
*
* Add an integer to the class. If the integer is already in the
* tree, then nothing is changed.
*/
void class_insert_codepoint(class_t*, uint32_t);
/** insert_range
*
* Add a range to class.
*/
void class_insert_range(class_t*, urange32_t);
/** remove
*
* Removes a given integer from the class. If the integer is not
* in the tree, then nothing is changed.
*/
void class_delete_codepoint(class_t*, uint32_t);
/** remove
*
* Removes a given range from the class.
*/
void class_delete_range(class_t*, urange32_t);
/** search
*
* Checks if a given codepoint is in the class. Guaranteed to run in
* O(lg(n)) time for a class consisting of n ranges.
*/
bool class_search(class_t*, uint32_t);
/** union
*
* Find the union of two classes. For this function and the following
* two, the left argument becomes the result of the operation.
*/
void class_union(class_t*, const class_t*);
/** intersection
*
* Takes the intersection of two classes.
*/
void class_intersection(class_t*, const class_t*);
/** difference
*
* Find the difference of the right argument from the left
* argument.
*/
void class_difference(class_t*, const class_t*);
/** empty
*
* Checks if a tree is empty.
*/
bool class_empty(class_t*);
/** cardinality
*
* Get the number of codepoints that are in the character class.
*/
int class_cardinality(class_t*);
/** size
*
* Get the number of disjoint ranges in the character class.
*/
int class_size(class_t*);
/** new
*
* Creates an empty class.
*/
class_t* class_new();
/** free
*
* Frees a tree's memory.
*/
void class_free(class_t*);
/** hook
*
* Debugger hook; print out all ranges in visiting order.
*/
#ifdef CLASS_HOOK
void class_hook(class_t*);
#endif /* ifdef CLASS_HOOK */
#endif