www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Bitarray size limits

reply "ixid" <nuaccount gmail.com> writes:
These seem to be limited to uint.max length. Is there a way to 
make larger bit arrays?
Apr 25 2012
next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
ixid:
 These seem to be limited to uint.max length. Is there a way to 
 make larger bit arrays?

Yeah, fixing the BigArray source :-) It's limited by size_t.max length, that equals to uint.max on 32 bit systems. It contains code like: struct BitArray { size_t len; size_t* ptr; property const size_t dim() { return (len + (bitsPerSizeT-1)) / bitsPerSizeT; } property const size_t length() { return len; } ... } To create larger arrays that 'len' needs to be a ulong. So it needs to become something like this: struct BitArray(bool hugeToo=false) { static if (hugeToo) { alias ulong Tindex; else alias size_t Tindex; Tindex len; size_t* ptr; property const Tindex dim() { return (len + (bitsPerSizeT - 1)) / bitsPerSizeT; } property const Tindex length() { return len; } ... } But this may cause some problems because BitArray is trying to look like a dynamic array, while now it's something that can be longer (and with a larger struct) than any dynamic array, so _from the outside too_ the management of its length needs extra care. Bye, bearophile
Apr 25 2012
prev sibling parent "ixid" <nuaccount gmail.com> writes:
Thank you, I will have a play with that.
Apr 25 2012