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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
use std::fmt::Debug;
use std::hash::Hash;
pub trait Count: Copy {
fn zero() -> Self;
fn add(&mut self, other: Self);
}
impl Count for u64 {
fn zero() -> Self {
0
}
fn add(&mut self, other: Self) {
*self += other;
}
}
impl Count for (u64, u64) {
fn zero() -> Self {
(0, 0)
}
fn add(&mut self, other: Self) {
self.0 += other.0;
self.1 += other.1;
}
}
pub trait Actor: Debug + Clone + Hash + Eq + Ord {}
impl<A: Debug + Clone + Hash + Eq + Ord> Actor for A {}
pub trait EventSet: IntoIterator + Clone + Debug {
fn new() -> Self;
fn from_event(event: u64) -> Self {
let mut eset = Self::new();
eset.add_event(event);
eset
}
fn from_event_range(start: u64, end: u64) -> Self {
let mut eset = Self::new();
eset.add_event_range(start, end);
eset
}
fn from_events<I: IntoIterator<Item = u64>>(iter: I) -> Self {
let mut eset = Self::new();
for event in iter {
eset.add_event(event);
}
eset
}
fn next_event(&mut self) -> u64;
fn add_event(&mut self, event: u64) -> bool;
fn add_event_range(&mut self, start: u64, end: u64) -> bool {
let mut res = false;
(start..=end).for_each(|event| {
let added = self.add_event(event);
res = res || added;
});
res
}
fn is_event(&self, event: u64) -> bool;
fn events(&self) -> (u64, Vec<u64>);
fn frontier(&self) -> u64;
fn join(&mut self, other: &Self);
}