-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboolean_set.h
56 lines (49 loc) · 1.67 KB
/
boolean_set.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
// Licensed under the MIT License.
#include <stdbool.h>
#include <stddef.h>
#include "exception.h"
/** Represents a set of boolean values. */
struct BooleanSet
{
bool* begin;
bool* end;
};
/** Represents a set of boolean values. */
typedef struct BooleanSet* BooleanSet;
/**
* Initializes a `BooleanSet` instance.
*
* @param instance the `BooleanSet` instance.
* @param capacity the required minimum capacity.
* @return `EXCEPTION_OUT_OF_MEMORY` if there is not enough memory to complete
* the operation; otherwise `0`.
*/
Exception boolean_set(BooleanSet instance, size_t capacity);
/**
* Intializes a static. `BooleanSet` instance. Do not call
* `finalize_boolean_set`.
*
* @param instance the `BooleanSet` instance.
* @param values the backing array for the set. The caller is responsible for
* this argument.
* @param length the length of the `values` argument.
*/
void boolean_set_from_array(BooleanSet instance, bool values[], size_t length);
/**
* Ensures that the capacity of this set is at least the specified capacity.
* If the current capacity is less than the required minimum capacity, it is
* increased to at least the specified capacity.
*
* @param instance the `BooleanSet` instance.
* @param capacity the required minimum capacity.
* @return `EXCEPTION_OUT_OF_MEMORY` if there is not enough memory to complete
* the operation; otherwise `0`.
*/
Exception boolean_set_ensure_capacity(BooleanSet instance, size_t capacity);
/**
* Frees all resources.
*
* @param instance the `BooleanSet` instance. This method corrupts the
* `instance` argument.
*/
void finalize_boolean_set(BooleanSet instance);