pub struct IntVectorMapper<'a> { /* private fields */ }Expand description
An immutable memory-mapped IntVector.
This is compatible with the serialization format of IntVector.
§Examples
use simple_sds_sbwt::int_vector::{IntVector, IntVectorMapper};
use simple_sds_sbwt::ops::{Vector, Access};
use simple_sds_sbwt::serialize::{MemoryMap, MemoryMapped, MappingMode};
use simple_sds_sbwt::serialize;
use std::fs;
let filename = serialize::temp_file_name("int-vector-mapper");
let mut v = IntVector::with_len(3, 13, 0).unwrap();
v.set(0, 123); v.set(1, 456); v.set(2, 789);
serialize::serialize_to(&v, &filename);
let map = MemoryMap::new(&filename, MappingMode::ReadOnly).unwrap();
let mapper = IntVectorMapper::new(&map, 0).unwrap();
assert_eq!(mapper.len(), v.len());
for i in 0..mapper.len() {
assert_eq!(mapper.get(i), v.get(i));
}
drop(mapper); drop(map);
fs::remove_file(&filename).unwrap();Trait Implementations§
Source§impl<'a> Access<'a> for IntVectorMapper<'a>
Available on non-target_family=wasm only.
impl<'a> Access<'a> for IntVectorMapper<'a>
Available on non-
target_family=wasm only.Source§type Iter = AccessIter<'a, IntVectorMapper<'a>>
type Iter = AccessIter<'a, IntVectorMapper<'a>>
Iterator over the items in the vector.
Source§fn get(&self, index: usize) -> <Self as Vector>::Item
fn get(&self, index: usize) -> <Self as Vector>::Item
Returns an item from the vector. Read more
Source§fn get_or(
&self,
index: usize,
value: <Self as Vector>::Item,
) -> <Self as Vector>::Item
fn get_or( &self, index: usize, value: <Self as Vector>::Item, ) -> <Self as Vector>::Item
Returns an item from the vector or the provided value if
index is invalid. Read moreSource§fn is_mutable(&self) -> bool
fn is_mutable(&self) -> bool
Returns
true if the underlying data is mutable. Read moreSource§impl<'a> AsRef<RawVectorMapper<'a>> for IntVectorMapper<'a>
Available on non-target_family=wasm only.
impl<'a> AsRef<RawVectorMapper<'a>> for IntVectorMapper<'a>
Available on non-
target_family=wasm only.Source§fn as_ref(&self) -> &RawVectorMapper<'a>
fn as_ref(&self) -> &RawVectorMapper<'a>
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl<'a> Debug for IntVectorMapper<'a>
impl<'a> Debug for IntVectorMapper<'a>
Source§impl<'a> MemoryMapped<'a> for IntVectorMapper<'a>
Available on non-target_family=wasm only.
impl<'a> MemoryMapped<'a> for IntVectorMapper<'a>
Available on non-
target_family=wasm only.Source§impl<'a> PartialEq for IntVectorMapper<'a>
impl<'a> PartialEq for IntVectorMapper<'a>
Source§impl<'a> Vector for IntVectorMapper<'a>
Available on non-target_family=wasm only.
impl<'a> Vector for IntVectorMapper<'a>
Available on non-
target_family=wasm only.impl<'a> Eq for IntVectorMapper<'a>
impl<'a> StructuralPartialEq for IntVectorMapper<'a>
Auto Trait Implementations§
impl<'a> Freeze for IntVectorMapper<'a>
impl<'a> RefUnwindSafe for IntVectorMapper<'a>
impl<'a> Send for IntVectorMapper<'a>
impl<'a> Sync for IntVectorMapper<'a>
impl<'a> Unpin for IntVectorMapper<'a>
impl<'a> UnwindSafe for IntVectorMapper<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more