Skip to content

Commit

Permalink
indexed: wip array
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed May 23, 2024
1 parent e408dd3 commit a3c34ba
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/value/indexed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,37 @@ use crate::{WidthInt, Word};

type WordIndex = u32;

#[derive(Debug)]
#[derive(Debug, Copy, Clone)]
pub struct BitVecValueIndex {
width: WidthInt,
index: WordIndex,
}

impl BitVecValueIndex {
fn new(index: WordIndex, width: WidthInt) -> Self {
#[inline]
pub fn new(index: WordIndex, width: WidthInt) -> Self {
Self { index, width }
}

#[inline]
fn words(&self) -> usize {
pub fn words(&self) -> usize {
self.width.div_ceil(Word::BITS) as usize
}

#[inline]
fn to_range(&self) -> std::ops::Range<usize> {
pub fn to_range(&self) -> std::ops::Range<usize> {
let start = self.index as usize;
let end = start + self.words();
start..end
}
}

#[derive(Debug, Copy, Clone)]
pub struct ArrayValueIndex {
first: BitVecValueIndex,
index_width: WidthInt,
}

pub struct ValueStorage<'a> {
values: &'a mut [Word],
}
Expand Down

0 comments on commit a3c34ba

Please sign in to comment.