Skip to content
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

SparseBitSet for a backtrackable bitset with mostly 0s. #935

Merged
merged 1 commit into from
Nov 28, 2022

Conversation

fhermeni
Copy link
Contributor

This implementation for IStateBitSet targets backtrackable bitsets that mostly contains 0. For non-dense bitsets, this implementation is more efficient in terms of memory usage as bitsets are allocated per region instead of relying on a single, possibly bit array. In this context, the iteration is also faster.

This implementation for IStateBitSet targets backtrackable bitsets that mostly contains 0.
For non-dense bitsets, this implementation is more efficient in terms of memory usage as bitsets are allocated per region instead of relying
on a single, possibly bit array. In this context, the iteration is also faster.
@fhermeni
Copy link
Contributor Author

This patch does not force any integration inside choco Environment given the criticality of that part. For the moment, this is just something I will have in btrplace and that may be useful for everyone.

@cprudhom cprudhom merged commit 849037d into chocoteam:master Nov 28, 2022
@cprudhom
Copy link
Member

cprudhom commented Oct 5, 2023

The following code throws an error:

    IEnvironment env = new EnvironmentTrailing();
    IStateBitSet bs = env.makeSparseBitset(64);
    bs.set(100);
    bs.set(200);
    bs.clear(101, 199);

Indeed, in SparseBitSet#clear(int,int), line 286:

      final int st;
      if (bIdx == blockIndex(from)) {
        st = from;
      } else {
        st = 0;
      }

st = from should be replaced by st = localIndex(from);

right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants