[−][src]Struct bv::BitSlice
A slice of a bit-vector; akin to &'a [bool]
but packed.
Examples
use bv::*; let array = [0b00110101u16]; let mut slice = array.bit_slice(..8); assert_eq!( slice[0], true ); assert_eq!( slice[1], false ); slice = slice.bit_slice(1..8); assert_eq!( slice[0], false ); assert_eq!( slice[1], true );
Methods
impl<'a, Block: BlockType> BitSlice<'a, Block>
[src]
pub fn from_slice(blocks: &'a [Block]) -> Self
[src]
Creates a BitSlice
from an array slice of blocks.
The size is always a multiple of
Block::nbits()
. If you want a different size, slice.
Examples
use bv::{BitSlice, BitSliceable}; let v = vec![0b01010011u16, 0u16]; let slice = BitSlice::from_slice(&v).bit_slice(..7); assert_eq!( slice.len(), 7 ); assert_eq!( slice[0], true ); assert_eq!( slice[1], true ); assert_eq!( slice[2], false );
pub unsafe fn from_raw_parts(bits: *const Block, offset: u64, len: u64) -> Self
[src]
Creates a BitSlice
from a pointer to its data, an offset where the bits start, and
the number of available bits.
This is unsafe because the size of the passed-in buffer is
not checked. It must hold at least offset + len
bits or the resulting behavior is
undefined.
Precondition
- the first
Block::ceil_div_nbits(len + offset)
words ofbits
safe to read.
pub fn len(&self) -> u64
[src]
The number of bits in the slice.
Examples
use bv::*; let bv: BitVec = bit_vec![ true, true, false, true ]; let slice = bv.bit_slice(..3); assert_eq!( bv.len(), 4 ); assert_eq!( slice.len(), 3 );
pub fn is_empty(&self) -> bool
[src]
Returns whether there are no bits in the slice.
Examples
use bv::*; let bv: BitVec = bit_vec![ true, true, false, true ]; let slice0 = bv.bit_slice(3..3); let slice1 = bv.bit_slice(3..4); assert!( slice0.is_empty() ); assert!( !slice1.is_empty() );
Trait Implementations
impl<'a, Block: BlockType> Bits for BitSlice<'a, Block>
[src]
type Block = Block
The underlying block type used to store the bits of the vector.
fn bit_len(&self) -> u64
[src]
fn get_bit(&self, position: u64) -> bool
[src]
fn get_block(&self, position: usize) -> Block
[src]
fn get_raw_block(&self, position: usize) -> Block
[src]
fn get_bits(&self, start: u64, count: usize) -> Self::Block
[src]
fn block_len(&self) -> usize
[src]
fn to_bit_vec(&self) -> BitVec<Self::Block>
[src]
impl<'a, Block: BlockType> BitSliceable<Range<u64>> for BitSlice<'a, Block>
[src]
impl<'a, Block: BlockType> BitSliceable<RangeInclusive<u64>> for BitSlice<'a, Block>
[src]
type Slice = Self
The type of the slice produced.
fn bit_slice(self, range: RangeInclusive<u64>) -> Self
[src]
impl<'a, Block: BlockType> BitSliceable<RangeFrom<u64>> for BitSlice<'a, Block>
[src]
type Slice = Self
The type of the slice produced.
fn bit_slice(self, range: RangeFrom<u64>) -> Self
[src]
impl<'a, Block: BlockType> BitSliceable<RangeTo<u64>> for BitSlice<'a, Block>
[src]
type Slice = Self
The type of the slice produced.
fn bit_slice(self, range: RangeTo<u64>) -> Self
[src]
impl<'a, Block: BlockType> BitSliceable<RangeToInclusive<u64>> for BitSlice<'a, Block>
[src]
type Slice = Self
The type of the slice produced.
fn bit_slice(self, range: RangeToInclusive<u64>) -> Self
[src]
impl<'a, Block: BlockType> BitSliceable<RangeFull> for BitSlice<'a, Block>
[src]
impl<'a, 'b, Block: BlockType> From<&'b BitSliceMut<'a, Block>> for BitSlice<'a, Block>
[src]
fn from(slice: &'b BitSliceMut<'a, Block>) -> Self
[src]
impl<'a, Block: BlockType> From<&'a [Block]> for BitSlice<'a, Block>
[src]
fn from(slice: &'a [Block]) -> Self
[src]
impl<'a, Block: Clone> Clone for BitSlice<'a, Block>
[src]
impl<'a, Block: Copy> Copy for BitSlice<'a, Block>
[src]
impl<'a, Block: BlockType> Eq for BitSlice<'a, Block>
[src]
impl<'a, Block: BlockType> Ord for BitSlice<'a, Block>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'a, Other: Bits> PartialEq<Other> for BitSlice<'a, Other::Block>
[src]
impl<'a, Block: BlockType> PartialOrd<BitSlice<'a, Block>> for BitSlice<'a, Block>
[src]
fn partial_cmp(&self, other: &BitSlice<Block>) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, Block: BlockType> Debug for BitSlice<'a, Block>
[src]
impl<'a, Block: BlockType> Index<u64> for BitSlice<'a, Block>
[src]
impl<'a, Block: BlockType + Hash> Hash for BitSlice<'a, Block>
[src]
Auto Trait Implementations
impl<'a, Block> !Send for BitSlice<'a, Block>
impl<'a, Block> !Sync for BitSlice<'a, Block>
impl<'a, Block> Unpin for BitSlice<'a, Block>
impl<'a, Block> UnwindSafe for BitSlice<'a, Block> where
Block: RefUnwindSafe,
Block: RefUnwindSafe,
impl<'a, Block> RefUnwindSafe for BitSlice<'a, Block> where
Block: RefUnwindSafe,
Block: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,