http://d.puremagic.com/issues/show_bug.cgi?id=6697

           Summary: std.bitmanip.FastBitMatrix
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2011-09-19 15:11:25 PDT ---
Created an attachment (id=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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to