Issue 6697 - std.bitmanip.FastBitMatrix
Summary: std.bitmanip.FastBitMatrix
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other Windows
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-19 15:11 UTC by bearophile_hugs
Modified: 2024-12-01 16:14 UTC (History)
1 user (show)

See Also:


Attachments
First version of the bit matrix (7.65 KB, application/octet-stream)
2011-09-19 15:11 UTC, bearophile_hugs
Details
Version 1.1 of the bit matrix (7.46 KB, application/octet-stream)
2011-09-19 17:38 UTC, bearophile_hugs
Details
Version 1.2 of the bit matrix (7.50 KB, application/octet-stream)
2011-09-19 17:43 UTC, bearophile_hugs
Details

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2011-09-19 15:11:25 UTC
Created attachment 1025 [details]
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.
Comment 1 bearophile_hugs 2011-09-19 17:38:09 UTC
Created attachment 1026 [details]
Version 1.1 of the bit matrix
Comment 2 bearophile_hugs 2011-09-19 17:43:27 UTC
Created attachment 1027 [details]
Version 1.2 of the bit matrix
Comment 3 Dmitry Olshansky 2012-05-30 06:31:53 UTC
Why not finalize 64-bit and make a pull request for it?
Comment 4 Dmitry Olshansky 2018-05-31 12:33:53 UTC
Would be nice for a DUB package not Phobos really.
Comment 5 dlangBugzillaToGithub 2024-12-01 16:14:25 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/9912

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB