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

Add a method to get a partition of BitVec #70

Closed
tsunrise opened this issue Nov 20, 2021 · 2 comments
Closed

Add a method to get a partition of BitVec #70

tsunrise opened this issue Nov 20, 2021 · 2 comments

Comments

@tsunrise
Copy link

It's sometimes helpful to get a partition of BitVec specified by a given range. Specifically, the following API might be useful:

/// Return a new `BitVec` at a given range. This operation is taking
/// O(range) time.
    pub fn get_range(&self, range: Range<usize>) -> Self;

This function will essentially copy range/block_size blocks with some constant time adjustments.

It's also helpful to have its iterator equivalent:

  pub fn iter(&self, range: Range<usize>) -> Iter<B> {
      self.ensure_invariant();
      Iter { bit_vec: self, range }
  }

Those two features will be useful in applications like MPC. It would be helpful if similar features are already implemented. Otherwise I can submit a PR. Thanks!

@pczarn
Copy link
Contributor

pczarn commented May 31, 2024

I'd call this fn range(&self, bounds: R) -> Iter<B> where R: ops::RangeBounds<usize>

@pczarn
Copy link
Contributor

pczarn commented Jul 1, 2024

With BitSlice, you'd do bvec[x .. y].to_bit_vec() or .iter()

Closing as a duplicate of #46

@pczarn pczarn closed this as completed Jul 1, 2024
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

No branches or pull requests

2 participants