Tuesday, November 18, 2014

TBitArray

   I looked around on the internet to see if there was any way for me to store individual bits in an array. The BitArray class exists but it states that it uses booleans to represent bits. I then went to look at how large booleans are. MSDN says it varies and on several threads the size ranges from 2-4 bytes. I haven't done any testing to see how much the actual size of booleans when used in the BitArray class but I went a head and threw together this TBitArray class anyways. Bits are stored in a byte array but each bit in the array is given an index instead of each byte given an index. 8bits = 1byte array, 9bits = 2byte array, 16bits = 2byte array, 17bits = 3byte array etc...


As always this might not be the best approach or implementation, if you have any issues or suggestions please leave a comment.