CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2010
    Posts
    4

    Looking for bitset library

    Hallo all,
    I'm looking for some good library, that works with bitsets or bitarrays. Anybody knows something better then boost:ynamic_bitset? No matter if the library is open source or commercial.

    Thanks,
    Volodymyr Tkachuk

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Looking for bitset library

    I would reach for std::bitset and/or boost:ynamic_bitset, so my answer would be no. What do you find lacking in dynamic_bitset?
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Looking for bitset library

    Roll your own from scratch or use the boost classes as a base ?
    It's not like working with bits is a very hard thing to do.
    I certainly wouldn't want to pay for a library just to fiddle some bits around.

    It's easy enough to write a bit class on top of some other storage class like CArray or std::vector.

  4. #4
    Join Date
    Oct 2010
    Posts
    4

    Re: Looking for bitset library

    In my project it is a common task to store and work with large bit masks, that contain less number of ones. So they could be compressed well in memory. I found one library called BitMagic (http://bmagic.sourceforge.net/), but also looking for other options.

  5. #5
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Looking for bitset library

    Are you aware that std::vector<bool> is space-optimized to work with bits?

  6. #6
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Looking for bitset library

    You say "large bit masks". How large? And does it really pay off to "compress" sparse bit masks?
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  7. #7
    Join Date
    Oct 2010
    Posts
    4

    Arrow Re: Looking for bitset library

    About 500 000 000 bits in a mask. So space optimization play a lot (as the program should work with several masks at the same time).

  8. #8
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Looking for bitset library

    You could have given us a bit more info about the reasons behind your question from the start. There's a big difference between asking for a library/class that can handle bitmasks. and a class that can handle something like 500 million bits, and where spacial compression could be beneficial.

    Just some bit fiddling is as I said easy and something you can roll on your own in an hours work at most. An efficient design for what you asking may very well need a solution that is tailor made to the specific problem domain, depending on how many actions you are doing on said mask.

    If you have a VERY sparse mask (say a couple hundred to thousand bits set), then it's possible the best solution is an implementation around an array/vector that just stores the indices of the enabled bits.
    This'll degrade fast as you need more enabled bits.

    There are other solutions. but it all depends on what you end up doing. A generic library may be easy, but it may also result in average or even downright bad performance on datasets or behaviour that isn't in line with what the generic library was conceived to solve.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured