How to add a bit at the start of BitSet buffer?

bitset, java

Solution

There is no way to insert bits at the front without copying.

Perhaps you could reverse the order of the bits in your `BitSet`? If you did, that would mean you're now appending bits to the end of the set, which can be done cheaply.

Alternatively, you could encapsulate a `Deque` of `BitSet`s. Then inserting bits at the front could be accomplished by inserting a new `BitSet` at the front of the `Deque`.

Problem

I am using a BitSet buffer where i have about 500 bits inside and i want to add about 10 bits at the start of the buffer, i mean at index 0 so the rest of the buffer should be shifted but I dont see a way to "add" a bit only write methods, so if i already have a bit there it will be replaced, no added. Is there any way to do this or i have to copy all to a temporary BitSet, add my 10 bits and then add my 500 bits ? Thank you :) PD: Sorry my bad English feel free of making corrections too :)

Original source