Efficient Sets for Small Enumerations
David F. Place <d <at> vidplace.com>
2006-04-03 12:19:25 GMT
Often when writing algorithms which involve set operations on small
enumerations, I start off using Data.Set. I soon find performance
requires rewriting that code to use bitwise operations. I miss the
nice interface of Data.Set and the type checking of using a proper
data type.
So, as an exercise in writing a library, I wrote out an
implementation of bitwise set operations using the interface of
Data.Set with a couple of extensions. It provides an abstract
interface and type checking. Using GHC -O3, code compiles right down
to the primitive bit-twiddling operators. My example program (a
sudoku solver) runs several times faster.
I'll be grateful for any feedback on this. Perhaps something like it
would be useful included in the standard libraries.
Cheers, David
--------------------------------
David F. Place
mailto:d <at> vidplace.com
_______________________________________________
Haskell-Cafe mailing list
(Continue reading)