-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathtinyset.dl
53 lines (45 loc) · 2.5 KB
/
tinyset.dl
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
/*
Copyright (c) 2021 VMware, Inc.
SPDX-License-Identifier: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/* `tinyset` (https://docs.rs/tinyset/0.2.2/tinyset/) is a Rust crate that
* implements several space-efficient sparse collections. This library is a
* wrapper around `tinyset` that so far only supports one of these types --
* `Set64`, which is a set of values that fit in 64 bits and can be cloned by
* copying (e.g., 8, 16, 32, or 64-bit integers). */
#[dyn_alloc]
#[iterate_by_val=iter:'X]
extern type Set64<'X>
extern function size(s: Set64<'X>): bit<64>
extern function empty(): Set64<'X>
extern function singleton(x: 'X): Set64<'X>
extern function insert(s: mut Set64<'X>, v: 'X): ()
extern function insert_imm(#[by_val] s: Set64<'X>, #[by_val] v: 'X): Set64<'X>
extern function contains(s: Set64<'X>, v: 'X): bool
extern function is_empty(s: Set64<'X>): bool
extern function nth(s: Set64<'X>, n: bit<64>): Option<bit<64>>
extern function union(#[by_val] s1: Set64<'X>, s2: Set64<'X>): Set64<'X>
extern function unions(sets: Vec<Set64<'X>>): Set64<'X>
extern function intersection(s1: Set64<'X>, s2: Set64<'X>): Set64<'X>
extern function difference(s1: Set64<'X>, s2: Set64<'X>): Set64<'X>
/* Aggregates */
extern function group_to_set(g: Group<'K, 'V>): Set64<'V>
extern function group_set_unions(g: Group<'K, Set64<'V>>): Set64<'V>
/* Optimized version of group_set_unions that, when the group consits of
* a single set, simply returns the reference to this set. */
extern function group_setref_unions(g: Group<'K, Ref<Set64<'V>>>): Ref<Set64<'V>>