pinam45 / dynamic_bitset Goto Github PK
View Code? Open in Web Editor NEWSimple Useful Libraries: C++17/20 header-only dynamic bitset
Home Page: https://pinam45.github.io/dynamic_bitset
License: MIT License
Simple Useful Libraries: C++17/20 header-only dynamic bitset
Home Page: https://pinam45.github.io/dynamic_bitset
License: MIT License
Could you probably add an own namespace? Otherwise it may be a bit difficult to use in larger projects.
To simplify serialization with json I use on my side a push_back_block:
constexpr void dynamic_bitset<Block, Allocator>::push_back_block(Block blockValue)
{
m_blocks.push_back(blockValue);
}
Binary serialization used .data();
for json 'for each block' save an uint32 or uint64 based on internal blocktype
The following is a comparison of different bitset implementations: https://cs.up.ac.za/cs/vpieterse/pub/PieterseEtAl_SAICSIT2010.pdf.
It would be interesting to see a similar comparison with this library.
Very cool,
I'm using it on my side with minor modification:
constexpr std::byte* data()
{
return reinterpret_cast<std::byte*>(&m_blocks[0]);
}
constexpr std::byte const* data() const
{
return reinterpret_cast<std::byte const*>(&m_blocks[0]);
}
Which is on my side convenient for binary serialization.
I didn't find an api that converts to long long, similar to the standard library's bitset
I wonder if we can make sul::dynamic_bitset compatible with fmt (https://fmt.dev/latest/index.html, https://hackingcpp.com/cpp/libs/fmt.html).
To do so, I think the missing is the begin/end accessing directly one bit with an iterator class (not for blocks) and an constructor with std::initializer_list< bool >.
https://hackingcpp.com/cpp/libs/fmt.html#panel-fold68a
Any thought on that?
Hi, I want to use this library in an openmp program. Since different threads can set bits in a same block, I wonder how I can set a bit atomically without using a mutex?
Binary (assignment) operations require the same size()
of their operands (example). While this makes the implementation easy it enforces additional boilerplate code if the user wants to use differently-sized sets.
The implementation will still be easy as the resulting bit set will either have the smaller or the larger of both size()
s:
In case of assignment operators I would expect the LHS operand to expand its size()
to fit the RHS if required. Of course, the loops must only iterate to the minimum of both sizes.
In case of binary operators it should be sufficient to swap LHS and RHS in order to avoid additional reallocations.
When debugging code that uses dynamic_bitset
with gdb
I get a segmentation fault when I try to print a bitset.
(gdb) print bitset[0]
$1 = {m_block = @0xd, m_mask = 93825020145982}
(gdb) print bitset
$2 = {Segmentation fault
Also, how should I read the output of the first print?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.