Struct bv::BitSliceMut [−][src]
pub struct BitSliceMut<'a, Block> { /* fields omitted */ }
A mutable slice of a bit-vector; akin to &'a mut [bool]
but packed.
Examples
use bv::*; let mut array = [0b00110101u16]; { let mut slice = BitSliceMut::from_slice(&mut array); assert_eq!( slice[0], true ); assert_eq!( slice[1], false ); slice.set_bit(0, false); } assert_eq!( array[0], 0b00110100u16 );
Methods
impl<'a, Block: BlockType> BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> BitSliceMut<'a, Block>
pub fn from_slice(blocks: &mut [Block]) -> Self
[src]
pub fn from_slice(blocks: &mut [Block]) -> Self
Creates a BitSliceMut
from a mutable array slice of blocks.
The size is always a multiple of Block::nbits()
. If you want a different size,
slice.
pub unsafe fn from_raw_parts(bits: *mut Block, offset: u8, len: u64) -> Self
[src]
pub unsafe fn from_raw_parts(bits: *mut Block, offset: u8, len: u64) -> Self
Creates a BitSliceMut
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.
pub fn len(&self) -> u64
[src]
pub fn len(&self) -> u64
The number of bits in the slice.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Returns whether there are no bits in the slice.
pub fn as_bit_slice(&self) -> BitSlice<'a, Block>
[src]
pub fn as_bit_slice(&self) -> BitSlice<'a, Block>
Converts a mutable bit slice to immutable.
Trait Implementations
impl<'a, 'b, Block: BlockType> From<&'b BitSliceMut<'a, Block>> for BitSlice<'a, Block>
[src]
impl<'a, 'b, Block: BlockType> From<&'b BitSliceMut<'a, Block>> for BitSlice<'a, Block>
fn from(slice: &'b BitSliceMut<'a, Block>) -> Self
[src]
fn from(slice: &'b BitSliceMut<'a, Block>) -> Self
Performs the conversion.
impl<'a, Block: BlockType> From<&'a mut [Block]> for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> From<&'a mut [Block]> for BitSliceMut<'a, Block>
fn from(slice: &'a mut [Block]) -> Self
[src]
fn from(slice: &'a mut [Block]) -> Self
Performs the conversion.
impl<'a, Block: BlockType> Bits for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> Bits for BitSliceMut<'a, Block>
type Block = Block
The underlying block type used to store the bits of the vector.
fn bit_len(&self) -> u64
[src]
fn bit_len(&self) -> u64
The length of the slice in bits.
fn get_bit(&self, position: u64) -> bool
[src]
fn get_bit(&self, position: u64) -> bool
Gets the bit at position
Read more
fn get_block(&self, position: usize) -> Block
[src]
fn get_block(&self, position: usize) -> Block
Gets the block at position
Read more
fn get_bits(&self, start: u64, count: usize) -> Self::Block
[src]
fn get_bits(&self, start: u64, count: usize) -> Self::Block
Gets count
bits starting at bit index start
, interpreted as a little-endian integer. Read more
fn block_len(&self) -> usize
[src]
fn block_len(&self) -> usize
The length of the slice in blocks.
fn to_bit_vec(&self) -> BitVec<Self::Block>
[src]
fn to_bit_vec(&self) -> BitVec<Self::Block>
Copies the bits into a new allocated [BitVec
]. Read more
impl<'a, Block: BlockType> BitsMut for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> BitsMut for BitSliceMut<'a, Block>
fn set_bit(&mut self, position: u64, value: bool)
[src]
fn set_bit(&mut self, position: u64, value: bool)
Sets the bit at position
to value
. Read more
fn set_block(&mut self, position: usize, value: Block)
[src]
fn set_block(&mut self, position: usize, value: Block)
Sets the block at position
to value
. Read more
fn set_bits(&mut self, start: u64, count: usize, value: Self::Block)
[src]
fn set_bits(&mut self, start: u64, count: usize, value: Self::Block)
Sets count
bits starting at bit index start
, interpreted as a little-endian integer. Read more
impl<'a, Block: BlockType> Index<u64> for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> Index<u64> for BitSliceMut<'a, Block>
type Output = bool
The returned type after indexing.
fn index(&self, index: u64) -> &bool
[src]
fn index(&self, index: u64) -> &bool
Performs the indexing (container[index]
) operation.
impl<'a, Block: BlockType> BitSliceable<Range<u64>> for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> BitSliceable<Range<u64>> for BitSliceMut<'a, Block>
type Slice = Self
The type of the slice produced.
fn bit_slice(self, range: Range<u64>) -> Self
[src]
fn bit_slice(self, range: Range<u64>) -> Self
Slices or re-slices the given object. Read more
impl<'a, Block: BlockType> BitSliceable<RangeInclusive<u64>> for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> BitSliceable<RangeInclusive<u64>> for BitSliceMut<'a, Block>
type Slice = Self
The type of the slice produced.
fn bit_slice(self, range: RangeInclusive<u64>) -> Self
[src]
fn bit_slice(self, range: RangeInclusive<u64>) -> Self
Slices or re-slices the given object. Read more
impl<'a, Block: BlockType> BitSliceable<RangeFrom<u64>> for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> BitSliceable<RangeFrom<u64>> for BitSliceMut<'a, Block>
type Slice = Self
The type of the slice produced.
fn bit_slice(self, range: RangeFrom<u64>) -> Self
[src]
fn bit_slice(self, range: RangeFrom<u64>) -> Self
Slices or re-slices the given object. Read more
impl<'a, Block: BlockType> BitSliceable<RangeTo<u64>> for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> BitSliceable<RangeTo<u64>> for BitSliceMut<'a, Block>
type Slice = Self
The type of the slice produced.
fn bit_slice(self, range: RangeTo<u64>) -> Self
[src]
fn bit_slice(self, range: RangeTo<u64>) -> Self
Slices or re-slices the given object. Read more
impl<'a, Block: BlockType> BitSliceable<RangeToInclusive<u64>> for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> BitSliceable<RangeToInclusive<u64>> for BitSliceMut<'a, Block>
type Slice = Self
The type of the slice produced.
fn bit_slice(self, range: RangeToInclusive<u64>) -> Self
[src]
fn bit_slice(self, range: RangeToInclusive<u64>) -> Self
Slices or re-slices the given object. Read more
impl<'a, Block: BlockType> BitSliceable<RangeFull> for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> BitSliceable<RangeFull> for BitSliceMut<'a, Block>
type Slice = Self
The type of the slice produced.
fn bit_slice(self, _: RangeFull) -> Self
[src]
fn bit_slice(self, _: RangeFull) -> Self
Slices or re-slices the given object. Read more
impl<'a, Other: Bits> PartialEq<Other> for BitSliceMut<'a, Other::Block>
[src]
impl<'a, Other: Bits> PartialEq<Other> for BitSliceMut<'a, Other::Block>
fn eq(&self, other: &Other) -> bool
[src]
fn eq(&self, other: &Other) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<'a, Block: BlockType> Eq for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> Eq for BitSliceMut<'a, Block>
impl<'a, Block: BlockType> PartialOrd for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> PartialOrd for BitSliceMut<'a, Block>
fn partial_cmp(&self, other: &BitSliceMut<Block>) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &BitSliceMut<Block>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<'a, Block: BlockType> Ord for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> Ord for BitSliceMut<'a, Block>
fn cmp(&self, other: &Self) -> Ordering
[src]
fn cmp(&self, other: &Self) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<'a, Block: BlockType + Hash> Hash for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType + Hash> Hash for BitSliceMut<'a, Block>
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<'a, Block: BlockType> Debug for BitSliceMut<'a, Block>
[src]
impl<'a, Block: BlockType> Debug for BitSliceMut<'a, Block>
Auto Trait Implementations
impl<'a, Block> !Send for BitSliceMut<'a, Block>
impl<'a, Block> !Send for BitSliceMut<'a, Block>
impl<'a, Block> !Sync for BitSliceMut<'a, Block>
impl<'a, Block> !Sync for BitSliceMut<'a, Block>