func (bA *CompactBitArray) GetIndex(i int) bool {
	if bA == nil {
		return false
	}
	if i >= bA.Size() {
		return false
	}
	return bA.Elems[i>>3]&(uint8(1)<<uint8(7-(i%8))) > 0
}
GetIndex returns the bit at index i within the bit array.
The behavior is undefined if i >= bA.Size()
package bitarray
import (
	"bytes"
	"encoding/binary"
	"errors"
	"fmt"
	"regexp"
	"strings"
)
type CompactBitArray struct {
	ExtraBitsStored byte   `json:"extra_bits"`  
	Elems           []byte `json:"bits"`
}
func NewCompactBitArray(bits int) *CompactBitArray {
	if bits <= 0 {
		return nil
	}
	return &CompactBitArray{
		ExtraBitsStored: byte(bits % 8),
		Elems:           make([]byte, (bits+7)/8),
	}
}
func (bA *CompactBitArray) Size() int {
	if bA == nil {
		return 0
	} else if bA.ExtraBitsStored == byte(0) {
		return len(bA.Elems) * 8
	}
	return (len(bA.Elems)-1)*8 + int(bA.ExtraBitsStored)
}