Coder Social home page Coder Social logo

pinam45 / dynamic_bitset Goto Github PK

View Code? Open in Web Editor NEW
151.0 151.0 15.0 901 KB

Simple Useful Libraries: C++17/20 header-only dynamic bitset

Home Page: https://pinam45.github.io/dynamic_bitset

License: MIT License

CMake 15.06% C++ 83.94% Batchfile 1.00%
catch2 cmake cpp17 cpp20 header-only sul unit-tests

dynamic_bitset's People

Contributors

pinam45 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dynamic_bitset's Issues

Add an own namespace

Could you probably add an own namespace? Otherwise it may be a bit difficult to use in larger projects.

push_back_block

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

Missing .data() for binary serialization

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.

Atomic operations

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 should not require the same `size()`

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.

gdb segmentation fault

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.