mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-03 15:23:41 -07:00
computer: remove the need for &mut vecs
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user