sux-rs icon indicating copy to clipboard operation
sux-rs copied to clipboard

Implemented double ended iterator for BitFieldVecIterator and associated tests

Open LucaCappelletti94 opened this issue 1 year ago • 3 comments

As per title, I have implemented DoubleEndedIterator for BitFieldVecIterator.

I have added in the test suite a couple of tests to verify that the double-ended iterator works as expected.

I have renamed a method into_iter_from to iter_from_start, and added additionally the methods iter_to_end and iter_range, alongside documentation.

LucaCappelletti94 avatar Apr 05 '24 17:04 LucaCappelletti94

Yes, iter_from and iter_to seem more in line with the rest of the software. What's the failed check?

BTW, thanks for the impl.

vigna avatar Apr 06 '24 07:04 vigna

Luca, if you could follow these guidelines that would be great. In particular, documentation is in third person.

But I see that now even a normal iterator uses twice the space, and stores twice the reference. I don't think this is a good design—double-ended will be a rare need, and we cannot duplicate the size for that rare case. The whole structure is designed with implementations are light as possible in mind.

You should at least implement a separate structure, ideally storing the reference once, but that would require to copy code from the two unchecked iterator, so let's say that's ok. Still, it would be better to have something like iter_de that returns a double-ended iterator (iter_de_from, etc.).

vigna avatar Apr 06 '24 08:04 vigna

You can find the benchmarks for the newly added apply_inplace method to update all values of a vector here. It can get to over 4 times faster than by using subsequent get & set operations.

LucaCappelletti94 avatar Apr 11 '24 09:04 LucaCappelletti94

Due to massive refactoring of the main branch this branch is no longer mergeable (besides its reported issues).

vigna avatar Jun 14 '24 07:06 vigna