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
use std::collections::{BTreeMap, HashMap};
use std::hash::Hash;
use std::marker::PhantomData;
use std::ops::Deref;
use num_traits::{Bounded, ToPrimitive, FromPrimitive};
use stable_deref_trait::StableDeref;
use arena_set::{Error, ArenaSet, StadiumSet};
pub struct Builder<O, I = usize> {
_o: PhantomData<O>,
_i: PhantomData<I>,
}
impl<O, I> Builder<O, I> {
pub fn new() -> Self {
Builder {
_o: PhantomData,
_i: PhantomData,
}
}
}
pub fn builder<O>() -> Builder<O> {
Builder::<O>::new()
}
impl<O, I> Builder<O, I>
where O: StableDeref,
I: Bounded + ToPrimitive + FromPrimitive
{
pub fn hash(&self) -> Result<ArenaSet<O, I, HashMap<&'static O::Target, I>>, Error>
where O::Target: Eq + Hash {
ArenaSet::new()
}
pub fn btree(&self) -> Result<ArenaSet<O, I, BTreeMap<&'static O::Target, I>>, Error>
where O::Target: Eq + Ord {
ArenaSet::new()
}
}
impl<O, I> Builder<O, I>
where O: StableDeref,
O::Target: 'static + StableDeref,
< O::Target as Deref >::Target: 'static,
I: Bounded + ToPrimitive + FromPrimitive
{
pub fn stadium_set_hash(&self) -> Result<StadiumSet<O, O::Target, I, HashMap<&'static < O::Target as Deref >::Target, I>>, Error>
where < O::Target as Deref >::Target: Eq + Hash {
ArenaSet::new().map(|p| StadiumSet(p))
}
pub fn stadium_set_btree(&self) -> Result<StadiumSet<O, O::Target, I, BTreeMap<&'static < O::Target as Deref >::Target, I>>, Error>
where < O::Target as Deref >::Target: Eq + Ord {
ArenaSet::new().map(|p| StadiumSet(p))
}
}