BitArray/BitFields - Review
Era Scarecrow
rtcvb32 at yahoo.com
Sun Jul 29 03:28:21 PDT 2012
On Sunday, 29 July 2012 at 09:30:06 UTC, Dmitry Olshansky wrote:
>
> I have simpler suggestion. Maybe doing it as 2 containers:
>
> BitSet is a plain value type with small array optimization
> (what you called BitArray in last 2 posts) and no slicing (only
> as opSlice() I.e. as a whole). Best used for small things under
> < 1000 bits (as even dup will be cheap enough).
>
> BitArray is class or struct that has reference smenatics and
> drops small array optimization in favor of having simple & fast
> slicing Best used for big arrays with no less then 100-200 bits.
As long as you only use one or the other then it sounds great;
I'm sure a conversion/constructor would be available to convert
from one to another. That does seem like the best solution, but
also feels like we're building it twice (Little code re-use).
Might be a third option: A template struct that represents a
BitArray type (with 90% of the code); you then insert a structure
with key functions that would handle the value/reference &
duplication part.
I'll meditate on it for a few days and see if anything pops up.
More information about the Digitalmars-d-learn
mailing list