diff options
Diffstat (limited to 'src/crates/library')
-rw-r--r-- | src/crates/library/src/adaptive.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/crates/library/src/adaptive.rs b/src/crates/library/src/adaptive.rs index 6708a07..179a2fa 100644 --- a/src/crates/library/src/adaptive.rs +++ b/src/crates/library/src/adaptive.rs @@ -28,18 +28,22 @@ macro_rules! get_inner { impl<const THRESHOLD: usize, LO: Default + Container<E>, HI: Default + Container<E>, E> Container<E> for AdaptiveContainer<THRESHOLD, LO, HI, E> { + #[inline(always)] fn len(&self) -> usize { get_inner!(self, c, c.len()) } + #[inline(always)] fn is_empty(&self) -> bool { get_inner!(self, c, c.is_empty()) } + #[inline(always)] fn contains(&self, x: &E) -> bool { get_inner!(self, c, c.contains(x)) } + #[inline(always)] fn insert(&mut self, elt: E) { get_inner!(self, c, c.insert(elt)); if let Self::Low(l, _) = self { @@ -56,14 +60,17 @@ impl<const THRESHOLD: usize, LO: Default + Container<E>, HI: Default + Container } } + #[inline(always)] fn remove(&mut self, elt: E) -> Option<E> { get_inner!(self, c, c.remove(elt)) } + #[inline(always)] fn clear(&mut self) { get_inner!(self, c, c.clear()) } + #[inline(always)] fn iter<'a>(&'a self) -> impl Iterator<Item = &'a E> where E: 'a, @@ -81,14 +88,17 @@ where LO: Mapping<K, V>, HI: Mapping<K, V>, { + #[inline(always)] fn len(&self) -> usize { get_inner!(self, c, c.len()) } + #[inline(always)] fn contains(&mut self, x: &K) -> bool { get_inner!(self, c, c.contains(x)) } + #[inline(always)] fn insert(&mut self, key: K, val: V) -> Option<V> { let res = get_inner!(self, c, c.insert(key, val)); if let Self::Low(l, _) = self { @@ -106,18 +116,22 @@ where res } + #[inline(always)] fn get(&self, key: &K) -> Option<&V> { get_inner!(self, c, c.get(key)) } + #[inline(always)] fn remove(&mut self, key: &K) -> Option<V> { get_inner!(self, c, c.remove(key)) } + #[inline(always)] fn clear(&mut self) { *self = Self::Low(LO::default(), PhantomData); } + #[inline(always)] fn iter<'a>(&'a self) -> impl Iterator<Item = (&'a K, &'a V)> + 'a where K: 'a, |