Replace another lock with an append-only vec
This commit is contained in:
parent
4699632637
commit
7edd1d8799
4 changed files with 20 additions and 4 deletions
|
@ -76,3 +76,19 @@ impl<T: Copy> AppendOnlyVec<T> {
|
|||
return self.vec.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Copy + PartialEq> AppendOnlyVec<T> {
|
||||
pub fn contains(&self, val: T) -> bool {
|
||||
for i in 0.. {
|
||||
match self.get(i) {
|
||||
None => return false,
|
||||
Some(v) => {
|
||||
if val == v {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue