-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhashset.qc
25 lines (22 loc) · 1.03 KB
/
hashset.qc
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
// The "hashset" type is a strong hash set of values. It can store any type of "type".
// If strings are stored, a ref to them is kept, so this can not be used as a weak set.
// Their absolute positions are kept track of, so iteration is constant time, but
// removals may shift the whole index table which might mess up iteration.
// Note that hashset_at does not do type checking! If the hashset only has one type being stored,
// you can safely leave out the type argument, otherwise be sure to do type checking.
accessor hashset : int;
hashset(optional int reserve) hashset_alloc = #0;
bool(hashset, type_t, variant value) hashset_add = #0;
bool(hashset, type_t, variant value) hashset_remove = #0;
bool(hashset, type_t, variant value) hashset_contains = #0
static int(hashset) hashset_get_length = #0;
void(hashset) hashset_clear = #0;
static variant(hashset, int index, optional out type_t) hashset_at = #0
accessor hashset : int
{
get int length = hashset_get_length;
inline get variant[int index] =
{
return hashset_at(this, index);
};
};