[][src]Struct fid::BitArray

pub struct BitArray { /* fields omitted */ }

Methods

impl BitArray[src]

pub fn new(size: usize) -> Self[src]

Returns a zero-cleared bit array of size size.

pub fn with_word_size(word_size: usize, len: usize) -> Self[src]

pub fn size(&self) -> usize[src]

Returns the size (byte) of the array.

pub fn set_bit(&mut self, i: usize, b: bool)[src]

Sets the bit at position i to b.

Examples

let mut ba = fid::BitArray::new(8);
ba.set_bit(3, true);
assert_eq!(ba.get_bit(3), true);
assert_eq!(ba.get_bit(4), false);
ba.set_bit(256, true);  // automatically extended
assert_eq!(ba.get_bit(256), true);

pub fn get_bit(&self, i: usize) -> bool[src]

Gets the bit at position i.

Panics

Panics if the specified position exceeds the capacity.

pub fn set_slice(&mut self, i: usize, slice_size: usize, slice: u64)[src]

Gets the slice of size slice_size at position i.

Panics

Panics if slice_size is greater than 64.

pub fn set_word(&mut self, i: usize, word_size: usize, word: u64)[src]

Sets the i-th word of size word_size to word.

Examples

let mut ba = fid::BitArray::new(128);
ba.set_word(0, 12, 0b0101_1010_1100);
assert_eq!(ba.get_word(0, 12), 0b0101_1010_1100);
ba.set_word(5, 12, 0b1010_0101_0011);
assert_eq!(ba.get_word(5, 12), 0b1010_0101_0011);

pub fn get_slice(&self, i: usize, slice_size: usize) -> u64[src]

Gets the slice of size slice_size at position i.

Panics

Panics if the end position of the slice exceeds the capacity or slice_size is greater than 64.

pub fn get_word(&self, i: usize, word_size: usize) -> u64[src]

Gets the i-th word of size word_size.

pub fn resize(&mut self, new_size: usize)[src]

Resizes the array.

Trait Implementations

impl Debug for BitArray[src]

impl Serialize for BitArray[src]

impl<'de> Deserialize<'de> for BitArray[src]

Auto Trait Implementations

impl Send for BitArray

impl Sync for BitArray

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]