Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4328182
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:38:48+00:00 2026-05-21T09:38:48+00:00

What is the fastest way to clear every kth bit in a boost::dynamic_bitset ,

  • 0

What is the fastest way to clear every kth bit in a boost::dynamic_bitset, optionally from offset j?

Currently I’m doing this which is pretty darn slow (pseudocode):

for (i = j; i < bitset.size(); i += k) {
    bitset[i] = 0;
}

Millions of bit-clears have to be done, so that’s why I’m looking for a fast way to do it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:38:48+00:00Added an answer on May 21, 2026 at 9:38 am

    For very large bitsets, compute a mask n bits long (where n is your native size, e.g. 64 for x86_64) as Nim suggested, apply it.
    If your native length is not a multiple of k, shift it accordingly.
    So if you have a native length of 10 and want to set only every 3rd bit of a 30 bit-long bitset, you’d need 3 passes like this:
    First 10 bits: 0010010010
    Second 10 bits: 0100100100
    Last 10 bits: 1001001001
    So, after applying each mask you’d need to shift it (n%k) bits to the left.

    Repeat until you’re done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the simple and fastest way to extract raw RGB data from a
What is the fastest way to implement a new class that inherits from List<T>
What is the absolute fastest way to read and write strings from a file
What is fastest way to remove the last character from a string? I have
Is the Visitor Pattern the fastest way to accomplish method parameter type identification (effectively
What is the fastest way to check if a string matches a certain pattern?
What's the fastest way to take a screenshot on windows? PIL.ImageGrab is rather slow..
What's the fastest way to get the length of an .net IEnumerable<T> in IronPython?
What is the fastest way to sum up an array in JavaScript? A quick
What is the fastest way to count lines and words in a text file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.