Quality-of-life API improvements.#32
Conversation
|
And I see now that between me looking at this again yesterday and deciding to do it, and actually doing it today, you did most of it anyways. Oops. =) |
|
Well it doesn't matter, too much, the main work I did yesterday was fix the padding thing in b478799, which enables the |
Adds: - `From<T> for BitVec` implementations for converting RsVec, BpTree and WaveletMatrix back into BitVecs - `impl Extend<BitVec> for BitVec` and `BitVec.extend_vec()` to append many bits at once - `BitVec.split_at()` and `._split_at_unchecked()` to split a BitVec into two halves
|
I rebased onto your branch and updated the From impls for RsVec and BpTree. Left WaveletMatrix as is for now. I'm pretty sure I added edit for you on the PR, so if you have a clear idea of what tests you want you can put them in. Otherwise, I can try to add some tests tomorrow. |
…ld be copying past the vector, or copying the same data twice
src/bit_vec/mod.rs
Outdated
|
|
||
| let iter_limbs = if leading_partial > 0 { | ||
| other.append_bits_unchecked( | ||
| self.data[first_limb] >> (WORD_SIZE - leading_partial), |
There was a problem hiding this comment.
This fails if the limb isn't WORD_SIZE long, see red test case.
|
Wow, I clearly didn't think the splitting logic through properly. Sorry for rushing making the PR and making you find the bugs first! I had a proper think about the algorithm and ended up with a factoring where the initial logic was more or less sound, but with an added edge case that needed handling where the split point is inside a partial last limb of the input vector. I also added a few more test cases. |
|
And I completely failed to see the unchecked set of tests just above. Sorry for being so sloppy again! |
|
There, now it passes the full test suite here. |
As we discussed in #31, From<> implementations for the types that seem to make sense (for EliasFano
.iter().collect()should suffice, and the RMQ types are Deref and aren't constructed from BitVecs). While using the library I've also felt the need for the extend and split functionality, so I added those while I was at it.Adds:
From<T> for BitVecimplementations for converting RsVec, BpTree and WaveletMatrix back into BitVecsimpl Extend<BitVec> for BitVecandBitVec.extend_vec()to append many bits at onceBitVec.split_at()and._split_at_unchecked()to split a BitVec into two halves