-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram_unordered_map.bpl
More file actions
32 lines (24 loc) · 1.02 KB
/
Copy pathprogram_unordered_map.bpl
File metadata and controls
32 lines (24 loc) · 1.02 KB
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
implements program
imports {
bapel.core
bapel.stl
}
fn testUnorderedMap() -> () {
let m: UnorderedMap String i64 = UnorderedMap::mk [String, i64] ();
core::print [bool] (UnorderedMap::empty [String, i64] &m);
core::print [i64] (UnorderedMap::size [String, i64] &m);
let key1: String = "hello".to_string;
UnorderedMap::insert [String, i64] (&m, key1, 42);
core::print [bool] (UnorderedMap::empty [String, i64] &m);
core::print [i64] (UnorderedMap::size [String, i64] &m);
let key2: String = "hello".to_string;
core::print [bool] (UnorderedMap::contains [String, i64] (&m, &key2));
let key3: String = "world".to_string;
core::print [bool] (UnorderedMap::contains [String, i64] (&m, &key3));
let opt1: Optional i64 = UnorderedMap::get [String, i64] (&m, &key2);
core::print [bool] (Optional::has_value [i64] &opt1);
core::print [i64] (Optional::get_value [i64] &opt1);
let opt2: Optional i64 = UnorderedMap::get [String, i64] (&m, &key3);
core::print [bool] (Optional::has_value [i64] &opt2);
()
}