(bytes []byte, numVals int)
| 73 | } |
| 74 | |
| 75 | func readBitArray(bytes []byte, numVals int) ( |
| 76 | bits []bool, |
| 77 | remaining []byte, |
| 78 | err error) { |
| 79 | |
| 80 | bytesUsed := ((numVals + 7) / 8) |
| 81 | |
| 82 | if len(bytes) < bytesUsed { |
| 83 | return nil, nil, errors.New("Not enough bytes") |
| 84 | } |
| 85 | |
| 86 | bitVector := make([]bool, numVals, numVals) |
| 87 | for i := 0; i < numVals; i++ { |
| 88 | bitVector[i] = (uint8(bytes[i/8]) & (1 << (uint(i) % 8))) != 0 |
| 89 | } |
| 90 | return bitVector, bytes[bytesUsed:], nil |
| 91 | } |
no test coverage detected