0

I would like to store numbers, from 1 to N, sequentially in an array of BitSet. Is there an alternate solution apart from using the set() method on each number? Thanks!

1 Answer 1

1

There are operations for setting a range of bits in a BitSet; e.g. set(from, to, value). So for example,

    for (int i = from; i < to; i++) {
        bitset.set(i, true);
    }

is equivalent to

    bitset.set(from, to, true);

The latter form is most likely a lot faster.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.