pub struct LProtoBitVec { /* private fields */ }
Expand description
§LProtoBitVec
: “Local Prototype Bitwise Vector”
A BitVec
where the bit-width and masking data (BitProto
) is saved directly in the struct
This is a thin wrapper around RawBitVec
that simply calls the underlying raw method and passes the associated
BitProto
along with it. Unlike RawBitVec
this is safe because it is impossible to ever use the wrong BitProto
§Pros
- Simpler, safer API than
RawBitVec
- No mono-morphization (smaller binary than
CProtoBitVec
) - Can store
LProtoBitVec
’s in a homogenous collection (Array
,Vec
,HashMap
, etc.) - Possible better cache-locality compared to
SProtoBitVec
(no pointer to heap)
§Cons
- A full copy of a
BitProto
stored in everyLProtoBitVec
(6 usize total) - No constant-propogation optimizations
Implementations§
Source§impl LProtoBitVec
impl LProtoBitVec
pub fn len(&self) -> usize
pub fn cap(&self) -> usize
pub fn free(&self) -> usize
pub fn new(proto: BitProto) -> Self
pub fn with_capacity(proto: BitProto, cap: usize) -> Self
pub fn grow_exact_for_additional_elements_if_needed( &mut self, extra_elements: usize, ) -> Result<(), String>
pub fn grow_exact_for_total_elements_if_needed( &mut self, total_elements: usize, ) -> Result<(), String>
pub fn grow_for_additional_elements_if_needed( &mut self, extra_elements: usize, ) -> Result<(), String>
pub fn grow_for_total_elements_if_needed( &mut self, total_elements: usize, ) -> Result<(), String>
pub fn clear(&mut self)
pub fn push(&mut self, val: usize) -> Result<(), String>
pub unsafe fn push_unchecked(&mut self, val: usize)
pub fn pop(&mut self) -> Result<usize, String>
pub unsafe fn pop_unchecked(&mut self) -> usize
pub fn insert(&mut self, idx: usize, val: usize) -> Result<(), String>
pub unsafe fn insert_unchecked(&mut self, idx: usize, val: usize)
pub fn insert_bitvec( &mut self, insert_idx: usize, bitvec: Self, ) -> Result<(), String>
pub unsafe fn insert_bitvec_unchecked( &mut self, insert_idx: usize, bitvec: Self, )
pub fn insert_iter<II, TO, ESI>(
&mut self,
insert_idx: usize,
source: II,
) -> Result<(), String>where
II: IntoIterator<Item = TO, IntoIter = ESI>,
TO: ToOwned<Owned = usize>,
ESI: ExactSizeIterator + Iterator<Item = TO>,
pub unsafe fn insert_iter_unchecked<II, TO, ESI>(
&mut self,
insert_idx: usize,
source: II,
)where
II: IntoIterator<Item = TO, IntoIter = ESI>,
TO: ToOwned<Owned = usize>,
ESI: ExactSizeIterator + Iterator<Item = TO>,
pub fn remove(&mut self, idx: usize) -> Result<usize, String>
pub unsafe fn remove_unchecked(&mut self, idx: usize) -> usize
pub fn remove_range(&mut self, idx_range: Range<usize>) -> Result<Self, String>
pub unsafe fn remove_range_unchecked(&mut self, idx_range: Range<usize>) -> Self
pub fn trim_range( &mut self, idx_range: RangeFrom<usize>, ) -> Result<Self, String>
pub unsafe fn trim_range_unchecked( &mut self, idx_range: RangeFrom<usize>, ) -> Self
pub fn swap(&mut self, idx_a: usize, idx_b: usize) -> Result<(), String>
pub unsafe fn swap_unchecked(&mut self, idx_a: usize, idx_b: usize)
pub fn swap_pop(&mut self, idx: usize) -> Result<usize, String>
pub unsafe fn swap_pop_unchecked(&mut self, idx: usize) -> usize
pub fn trim_excess_capacity( &mut self, extra_capacity_to_keep: usize, ) -> Result<(), String>
pub fn append_bitvec(&mut self, bitvec: Self) -> Result<(), String>
pub unsafe fn append_bitvec_unchecked(&mut self, bitvec: Self)
pub fn append_iter<II, TO, ESI>(&mut self, source: II) -> Result<(), String>where
II: IntoIterator<Item = TO, IntoIter = ESI>,
TO: ToOwned<Owned = usize>,
ESI: ExactSizeIterator + Iterator<Item = TO>,
pub unsafe fn append_iter_unchecked<I, TO>(&mut self, iter: I)
pub fn get(&self, idx: usize) -> Result<usize, String>
pub unsafe fn get_unchecked(&self, idx: usize) -> usize
pub fn replace(&mut self, idx: usize, val: usize) -> Result<usize, String>
pub unsafe fn replace_unchecked(&mut self, idx: usize, val: usize) -> usize
pub fn set(&mut self, idx: usize, val: usize) -> Result<(), String>
pub unsafe fn set_unchecked(&mut self, idx: usize, val: usize)
pub fn discard_from_end(&mut self, count: usize)
pub fn drain<'vec>(&'vec mut self) -> LProtoBitVecDrain<'vec> ⓘ
pub unsafe fn into_raw(self) -> RawBitVec
Trait Implementations§
Source§impl Drop for LProtoBitVec
impl Drop for LProtoBitVec
Auto Trait Implementations§
impl Freeze for LProtoBitVec
impl RefUnwindSafe for LProtoBitVec
impl !Send for LProtoBitVec
impl !Sync for LProtoBitVec
impl Unpin for LProtoBitVec
impl UnwindSafe for LProtoBitVec
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