Struct tree_index::Bitfield [−][src]
pub struct Bitfield {
pub pages: Pager,
// some fields omitted
}Bitfield instance.
Fields
pages: Pager
A memory-pager instance.
Methods
impl Bitfield[src]
impl Bitfieldpub fn new(page_size: usize) -> Bitfield[src]
pub fn new(page_size: usize) -> Bitfieldpub fn set(&mut self, index: usize, value: bool) -> Change[src]
pub fn set(&mut self, index: usize, value: bool) -> ChangeSet a byte to true or false. Returns a boolean indicating if the value was changed.
pub fn get(&mut self, index: usize) -> bool[src]
pub fn get(&mut self, index: usize) -> boolGet the value of a bit.
pub fn get_byte(&self, index: usize) -> u8[src]
pub fn get_byte(&self, index: usize) -> u8Get a byte from our internal buffers.
pub fn set_byte(&mut self, index: usize, byte: u8) -> Change[src]
pub fn set_byte(&mut self, index: usize, byte: u8) -> ChangeSet a byte to the right value inside our internal buffers.
pub fn page_size(&self) -> usize[src]
pub fn page_size(&self) -> usizeGet the memory page size in bytes.
pub fn len(&self) -> usize[src]
pub fn len(&self) -> usizeGet the amount of bits in the bitfield.
Examples
let mut bits = Bitfield::new(1024); assert_eq!(bits.len(), 0); bits.set(0, true); assert_eq!(bits.len(), 8); bits.set(1, true); assert_eq!(bits.len(), 8); bits.set(9, false); assert_eq!(bits.len(), 16);
pub fn byte_len(&self) -> usize[src]
pub fn byte_len(&self) -> usizeGet the amount of bytes in the bitfield.
Examples
let mut bits = Bitfield::new(1024); assert_eq!(bits.byte_len(), 0); bits.set(0, true); assert_eq!(bits.byte_len(), 1); bits.set(1, true); assert_eq!(bits.byte_len(), 1); bits.set(9, false); assert_eq!(bits.byte_len(), 2);
pub fn is_empty(&self) -> bool[src]
pub fn is_empty(&self) -> boolReturns true if no bits are stored.
Examples
let mut bits = Bitfield::new(1024); assert!(bits.is_empty()); bits.set(0, true); assert!(!bits.is_empty());
ⓘImportant traits for Iter<'a>pub fn iter(&mut self) -> Iter[src]
ⓘImportant traits for Iter<'a>
pub fn iter(&mut self) -> IterCreate an Iterator that iterates over all pages.
Trait Implementations
impl Default for Bitfield[src]
impl Default for BitfieldCreate a new instance with a page_size of 1kb.
impl Debug for Bitfield[src]
impl Debug for Bitfield