Files
@ 031c9d14adaa
Branch filter:
Location: CSY/reowolf/src/collections/sets.rs - annotation
031c9d14adaa
2.0 KiB
application/rls-services+xml
Merge branch 'feat-bytecode'
Adds size/alignment/offset computations to the type system and detects
potentially infinite types. If the type is potentially infinite but
contains a union that can break that type loop, then all other variants
of that union are supposed to be allocated on the heap. If the type
is potentially infinite but cannot be broken up, then we throw the
appropriate error.
The size/alignment/offset computations are not yet employed in the
runtime. But prepares Reowolf for a proper bytecode/IR implementation.
Adds size/alignment/offset computations to the type system and detects
potentially infinite types. If the type is potentially infinite but
contains a union that can break that type loop, then all other variants
of that union are supposed to be allocated on the heap. If the type
is potentially infinite but cannot be broken up, then we throw the
appropriate error.
The size/alignment/offset computations are not yet employed in the
runtime. But prepares Reowolf for a proper bytecode/IR implementation.
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 10d2e43f1350 10d2e43f1350 10d2e43f1350 10d2e43f1350 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 is_empty(&self) -> bool {
self.inner.is_empty()
}
}
|