-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement BitArray
type?
#112
Comments
Array without the word "dynamic" means fixed length, so I'd call this like ferrilabs: Could be done like this pub trait BitStore {
fn get(&self, idx: usize) -> bool;
fn push(&mut self, elem: bool);
}
pub struct DynamicBitStore<B: BitBlock> {
ary: Vec<B>,
}
pub struct HybridBitStore<B: BitBlock> {
Stack([B; 3]),
Heap(DynamicBitStore<B>),
}
impl<B: BitBlock> BitStore for DynamicBitStore<B>
impl<B: BitBlock> BitStore for HybridBitStore<B>
struct BitVec<S: BitStore> {
store: S,
nbits: usize,
}
// BitCursorSlice |
Okay, So I may be wrong, because ferrilabs have stuff like |
I think that's useless to have bit storage which may be either stack or heap allocated The
|
The goal is to have |
It wasn't obvious from my code, so it could have confused you, but that's my intention |
Then what's the point of |
Ah, I see But I do believe that this is misleading: It would be much simpler (and, in fact, more convenient) to leave @pczarn , what do you think? |
@Jujumba there is truth to what you said about simplicity, my new, much simpler idea is to introduce |
@Jujumba The |
Also, I'd call it |
And you want to add these structures as a possible buffer to |
@Jujumba Yes, that's right |
And how that "hybrid" vector will extend itself if it exceeds capacity? |
@Jujumba the SmallVec takes care of that. First, it puts bits on the stack, and once the capacity of the stack is exceeded, it allocates onto the heap, behaving just like a Vec. It remains on the heap forever unless you call In my estimation, we could store 64 bits with SmallVec, or up to 95 bits with our new very custom implementation for storing bits, on the stack. Edit: on 64-bit machines, it will be 128 bits and up to 173 bits. |
This is just like some Rust libraries that can store up to 23 characters/bytes long strings on the stack within a 24 byte info of a dynamic array. You can make the same thing with bits, and SmallVec provides kinda that. |
We could still achieve that with |
This may also help to close #9
The text was updated successfully, but these errors were encountered: