computer: remove the need for &mut vecs

This commit is contained in:
nym21
2025-04-28 11:21:28 +02:00
parent 9ae0a57f22
commit 15e6ef8488
19 changed files with 737 additions and 707 deletions
+23 -1
View File
@@ -249,7 +249,18 @@ where
I: StoredIndex,
T: StoredType,
{
pub fn get(&mut self, i: usize) -> Option<(I, Value<'a, T>)> {
#[inline]
pub fn unwrap_get_inner(&mut self, i: I) -> T {
self.get_(i.unwrap_to_usize()).unwrap().1.into_inner()
}
#[inline]
pub fn get(&mut self, i: I) -> Option<(I, Value<'a, T>)> {
self.get_(i.unwrap_to_usize())
}
#[inline]
pub fn get_(&mut self, i: usize) -> Option<(I, Value<'a, T>)> {
match self {
Self::Compressed(iter) => {
iter.set(i);
@@ -261,6 +272,17 @@ where
}
}
}
pub fn set(&mut self, i: I) {
match self {
Self::Compressed(iter) => {
iter.set(i.unwrap_to_usize());
}
Self::Raw(iter) => {
iter.set(i.unwrap_to_usize());
}
}
}
}
impl<'a, I, T> Iterator for StoredVecIterator<'a, I, T>
+5 -4
View File
@@ -104,10 +104,10 @@ where
fn collect_range(&self, from: Option<usize>, to: Option<usize>) -> Result<Vec<Self::T>>;
#[inline]
fn collect_inclusive_range(&self, from: I, to: I) -> Result<Vec<Self::T>> {
self.collect_range(Some(from.to_usize()?), Some(to.to_usize()? + 1))
}
// #[inline]
// fn collect_inclusive_range(&self, from: I, to: I) -> Result<Vec<Self::T>> {
// self.collect_range(Some(from.to_usize()?), Some(to.to_usize()? + 1))
// }
#[inline]
fn i64_to_usize(i: i64, len: usize) -> usize {
@@ -119,6 +119,7 @@ where
}
}
#[doc(hidden)]
fn collect_signed_range(&self, from: Option<i64>, to: Option<i64>) -> Result<Vec<Self::T>> {
let len = self.len();
let from = from.map(|i| Self::i64_to_usize(i, len));