Struct TypedBitVec

Source
pub struct TypedBitVec<T: TypedBitElem>(/* private fields */);
Expand description

§TypedBitVec: “Typed Bitwise Vector”

A BitVec where all the data needed to access and translate the generic <T> to and from the expected usize is stored in a monomorphized constant inside the trait TypedBitElem

This is a thin wrapper around RawBitVec that simply calls the underlying raw method and passes the associated BitProto along with it, translating the input type to and from usize according to the specific implementation of TypedBitElem. Unlike RawBitVec this is safe because it is impossible to ever use the wrong BitProto

§Pros

  • Simpler, safer API than RawBitVec
  • Same stack-size as RawBitVec and Vec (3 usize)
  • Allows for constant-propogation optimizations
  • Values are automatically translated to and from the generic type <T>

§Cons

  • Every separate value of <T> creates a distinct type with its own copy of all methods (larger binary)
  • Cannot store TypedBitVec’s with diferent <T>’s in the same homogenous collection (Array, Vec, HashMap, etc.)
  • May require aditional processing to translate the normal usize to and from <T>
  • <T> must implement TypedBitElem (simple integer implementations are provided via crate features)

Implementations§

Source§

impl<T: TypedBitElem> TypedBitVec<T>

Source

pub fn len(&self) -> usize

Source

pub fn cap(&self) -> usize

Source

pub fn free(&self) -> usize

Source

pub fn new() -> Self

Source

pub fn with_capacity(cap: usize) -> Self

Source

pub fn grow_exact_for_additional_elements_if_needed( &mut self, extra_elements: usize, ) -> Result<(), String>

Source

pub fn grow_exact_for_total_elements_if_needed( &mut self, total_elements: usize, ) -> Result<(), String>

Source

pub fn grow_for_additional_elements_if_needed( &mut self, extra_elements: usize, ) -> Result<(), String>

Source

pub fn grow_for_total_elements_if_needed( &mut self, total_elements: usize, ) -> Result<(), String>

Source

pub fn clear(&mut self)

Source

pub fn push(&mut self, val: T::Base) -> Result<(), String>

Source

pub unsafe fn push_unchecked(&mut self, val: T::Base)

Source

pub fn pop(&mut self) -> Result<T::Base, String>

Source

pub unsafe fn pop_unchecked(&mut self) -> T::Base

Source

pub fn insert(&mut self, idx: usize, val: T::Base) -> Result<(), String>

Source

pub unsafe fn insert_unchecked(&mut self, idx: usize, val: T::Base)

Source

pub fn insert_bitvec( &mut self, insert_idx: usize, bitvec: Self, ) -> Result<(), String>

Source

pub unsafe fn insert_bitvec_unchecked( &mut self, insert_idx: usize, bitvec: Self, )

Source

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>,

Source

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>,

Source

pub fn remove(&mut self, idx: usize) -> Result<T::Base, String>

Source

pub unsafe fn remove_unchecked(&mut self, idx: usize) -> T::Base

Source

pub fn remove_range(&mut self, idx_range: Range<usize>) -> Result<Self, String>

Source

pub unsafe fn remove_range_unchecked(&mut self, idx_range: Range<usize>) -> Self

Source

pub fn trim_range( &mut self, idx_range: RangeFrom<usize>, ) -> Result<Self, String>

Source

pub unsafe fn trim_range_unchecked( &mut self, idx_range: RangeFrom<usize>, ) -> Self

Source

pub fn swap(&mut self, idx_a: usize, idx_b: usize) -> Result<(), String>

Source

pub unsafe fn swap_unchecked(&mut self, idx_a: usize, idx_b: usize)

Source

pub fn swap_pop(&mut self, idx: usize) -> Result<T::Base, String>

Source

pub unsafe fn swap_pop_unchecked(&mut self, idx: usize) -> T::Base

Source

pub fn trim_excess_capacity( &mut self, extra_capacity_to_keep: usize, ) -> Result<(), String>

Source

pub fn append_bitvec(&mut self, bitvec: Self) -> Result<(), String>

Source

pub unsafe fn append_bitvec_unchecked(&mut self, bitvec: Self)

Source

pub fn append_iter<II, TO, ESI>(&mut self, source: II) -> Result<(), String>
where II: IntoIterator<Item = TO, IntoIter = ESI>, TO: ToOwned<Owned = T::Base>, ESI: ExactSizeIterator + Iterator<Item = TO>,

Source

pub unsafe fn append_iter_unchecked<I, TO>(&mut self, iter: I)
where I: Iterator<Item = TO> + ExactSizeIterator, TO: ToOwned<Owned = T::Base>,

Source

pub fn get(&self, idx: usize) -> Result<T::Base, String>

Source

pub unsafe fn get_unchecked(&self, idx: usize) -> T::Base

Source

pub fn replace(&mut self, idx: usize, val: T::Base) -> Result<T::Base, String>

Source

pub unsafe fn replace_unchecked(&mut self, idx: usize, val: T::Base) -> T::Base

Source

pub fn set(&mut self, idx: usize, val: T::Base) -> Result<(), String>

Source

pub unsafe fn set_unchecked(&mut self, idx: usize, val: T::Base)

Source

pub fn discard_from_end(&mut self, count: usize)

Source

pub fn drain<'vec>(&'vec mut self) -> TypedBitVecDrain<'vec, T>

Source

pub unsafe fn into_raw(self) -> RawBitVec

Trait Implementations§

Source§

impl<T: TypedBitElem> Drop for TypedBitVec<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: TypedBitElem> IntoIterator for TypedBitVec<T>

Source§

type Item = <T as TypedBitElem>::Base

The type of the elements being iterated over.
Source§

type IntoIter = TypedBitVecIter<T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<T> Freeze for TypedBitVec<T>

§

impl<T> RefUnwindSafe for TypedBitVec<T>
where T: RefUnwindSafe,

§

impl<T> !Send for TypedBitVec<T>

§

impl<T> !Sync for TypedBitVec<T>

§

impl<T> Unpin for TypedBitVec<T>
where T: Unpin,

§

impl<T> UnwindSafe for TypedBitVec<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.