Files
@ 36cc1fe490f7
Branch filter:
Location: CSY/reowolf/src/collections/sets.rs - annotation
36cc1fe490f7
2.3 KiB
application/rls-services+xml
Merge branch 'feat-api-cmds-and-branching'
Implements the programmer-facing API to allow programmatic
specification of a synchronous round. The way in which these put/get
interactions are performed is in an initial shape. Perhaps this will
change in the future.
The second main set of changes is the addion of a 'fork' statement,
which allows explicit forking, and allowing multiple puts/gets over the
same transport link within a single sync round.
Implements the programmer-facing API to allow programmatic
specification of a synchronous round. The way in which these put/get
interactions are performed is in an initial shape. Perhaps this will
change in the future.
The second main set of changes is the addion of a 'fork' statement,
which allows explicit forking, and allowing multiple puts/gets over the
same transport link within a single sync round.
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 | 5dea649b3ffd 5dea649b3ffd 10d2e43f1350 10d2e43f1350 10d2e43f1350 ef37386d0c6f 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 85419b0950c7 85419b0950c7 85419b0950c7 85419b0950c7 85419b0950c7 ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f ef37386d0c6f 649f3bb14317 edb4c4be7e45 649f3bb14317 649f3bb14317 649f3bb14317 32d91577e090 32d91577e090 32d91577e090 32d91577e090 32d91577e090 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 54917d00dfe6 54917d00dfe6 54917d00dfe6 54917d00dfe6 54917d00dfe6 10d2e43f1350 | #![allow(dead_code)] // For now, come back to this when compiler has matured -- MH 27/05/21
use std::collections::VecDeque;
/// Simple double ended queue that ensures that all elements are unique. Queue
/// elements are not ordered (we expect the queue to be rather small).
pub struct DequeSet<T: Eq> {
inner: VecDeque<T>,
}
impl<T: Eq> DequeSet<T> {
pub fn new() -> Self {
Self{ inner: VecDeque::new() }
}
#[inline]
pub fn pop_front(&mut self) -> Option<T> {
self.inner.pop_front()
}
#[inline]
pub fn pop_back(&mut self) -> Option<T> {
self.inner.pop_back()
}
#[inline]
pub fn push_back(&mut self, to_push: T) {
for element in self.inner.iter() {
if *element == to_push {
return;
}
}
self.inner.push_back(to_push);
}
#[inline]
pub fn push_front(&mut self, to_push: T) {
for element in self.inner.iter() {
if *element == to_push {
return;
}
}
self.inner.push_front(to_push);
}
#[inline]
pub fn clear(&mut self) {
self.inner.clear();
}
#[inline]
pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}
}
/// Simple vector set that ensures that all elements are unique. Elements are
/// not ordered (we expect the vector to be small).
pub struct VecSet<T: Eq> {
inner: Vec<T>,
}
impl<T: Eq> VecSet<T> {
pub fn new() -> Self {
Self{ inner: Vec::new() }
}
#[inline]
pub fn pop(&mut self) -> Option<T> {
self.inner.pop()
}
#[inline]
pub fn push(&mut self, to_push: T) {
for element in self.inner.iter() {
if *element == to_push {
return;
}
}
self.inner.push(to_push);
}
#[inline]
pub fn clear(&mut self) {
self.inner.clear();
}
#[inline]
pub fn iter(&self) -> impl Iterator<Item=&T> {
return self.inner.iter();
}
#[inline]
pub fn contains(&self, item: &T) -> bool {
return self.inner.contains(item);
}
#[inline]
pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}
#[inline]
pub fn into_vec(self) -> Vec<T> {
return self.inner;
}
}
|