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

std.bitmanip.FastBitMatrix #9912

Open
dlangBugzillaToGithub opened this issue Sep 19, 2011 · 4 comments
Open

std.bitmanip.FastBitMatrix #9912

dlangBugzillaToGithub opened this issue Sep 19, 2011 · 4 comments
Labels
OS:Windows Issues Specific to Windows Severity:Enhancement

Comments

@dlangBugzillaToGithub
Copy link

bearophile_hugs reported this on 2011-09-19T15:11:25Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=6697

CC List

Description

Created attachment 1025
First version of the bit matrix

I suggest to add a fast 2D matrix of bits to Phobos (probably in std_bitmanip):
- It is a common enough data structure, useful for simple implementations of
various games, cellular automata, 2D sets, and more.
- Despite being a simple data structure, it's not obvious, especially if you
want it to be fast. A naive implementation that uses a BitArray is not fast
enough.
- It doesn't need to be too much general. A 3D bit array is in my experience
quite less commonly useful, and the implementation is different enough.


In attach there is an efficient implementation, that I have used it for several
purposes. Some notes:
- It wastes a bit of RAM to be faster.
- I have named it FastBitMatrix because "Fast" helps remember this 2D matrix
wastes some memory to be as fast as possible.
- It uses two little commonly useful functions that in my opinion are better
moved in std.math.
- Currently it allocates memory with a normal dynamic array. With a small
change it's usable with smarter/faster allocators.
- There are ddocs and unittests for all the functions (but the unittests of
FastBitMatrix don't test its contracts).
- I have not tried it on 64 bit systems.
- Optional are a toString/writeTo method, a copy method, postblit, and other
constructors.
- Currently it's just a struct with value semantics.

!!!There are attachements in the bugzilla issue that have not been copied over!!!

@dlangBugzillaToGithub
Copy link
Author

bearophile_hugs commented on 2011-09-19T17:38:09Z

Created attachment 1026
Version 1.1 of the bit matrix

@dlangBugzillaToGithub
Copy link
Author

bearophile_hugs commented on 2011-09-19T17:43:27Z

Created attachment 1027
Version 1.2 of the bit matrix

@dlangBugzillaToGithub
Copy link
Author

dmitry.olsh (@DmitryOlshansky) commented on 2012-05-30T06:31:53Z

Why not finalize 64-bit and make a pull request for it?

@dlangBugzillaToGithub
Copy link
Author

dmitry.olsh (@DmitryOlshansky) commented on 2018-05-31T12:33:53Z

Would be nice for a DUB package not Phobos really.

@LightBender LightBender removed the P4 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS:Windows Issues Specific to Windows Severity:Enhancement
Projects
None yet
Development

No branches or pull requests

2 participants