On Tuesday, 15 May 2012 at 20:50:27 UTC, ixid wrote:
So if that will not work how would I efficiently copy an array of BitArray? Looping through each bit is very slow. An array of bool
arrays is fine but I want to try to reduce the memory needed for
memoization of an algorithm.

That wouldn't be looping through each bit. That would be looping through each BitArray which contain multiple bits.

In other words, that's still efficient enough. Ideally if you know exactly how many bits you need (and it doesn't change), you could write your own struct that doesn't use the indirection (would use a static array) to get maximum performance and maximize the compression. However, many argue that's premature optimization ... but I think it's okay if you're trying to learn how to push the boundaries of the optimization of your algorithm.

Also, Array!bool is smart ... it compacts the bools down like BitArray does. I'm not sure which would be preferable, but they both operate somewhat similarly. For what it's worth, it appears Array!bool is newer and uses Ranges.

Reply via email to