func (a *Array) Get(idx, size int) uint64 {
	if idx > a.length {
		panic("bit: index out of bounds")
	} else if size <= 0 || size > 64 {
		panic("bit: bit size must be in range [1,64]")
	}
	bitIdx := idx & 63
	arrayIdx := idx >> 6
	lowBitSz := 64 - bitIdx
	overflow := size - lowBitSz
	res := a.bits[arrayIdx] >> uint(bitIdx)
	if overflow > 0 {
		res |= a.bits[arrayIdx+1] << uint(lowBitSz)
	}
	return res & ((1 << uint(size)) - 1)
}
Get returns the uint64 representation of
bits starting from index idx given the bit size.
package bit
import (
	"bytes"
	"encoding/gob"
	"fmt"
	"strings"
)
type Array struct {
	bits   []uint64
	length int
}
func NewArray(n int) *Array {
	if n < 0 {
		panic("bit: array size must be greater than or equal 0")
	}
	b := make([]uint64, 1, (n>>6)+1)
	return &Array{b, 0}
}
func (a *Array) Add(bits uint64, size int) {
	if size <= 0 || size > 64 {
		panic("bit: bit size must be in range [1,64]")
	}
	lenbits := len(a.bits)
	freespace := (lenbits << 6) - a.length
	overflow := size - freespace
	if overflow > 0 {
		a.bits = append(a.bits, 0)
	}
	idx := lenbits - 1
	if freespace > 0 {
		a.bits[idx] |= bits << uint(a.length&63)
	}
	if overflow > 0 {
		a.bits[idx+1] |= bits >> uint(freespace)
	}
	a.length += size
}
func (a *Array) Insert(idx int, bits uint64, size int) {
	if idx > a.length {
		panic("bit: index out of bounds")
	} else if size <= 0 || size > 64 {
		panic("bit: bit size must be in range [1,64]")
	}
	overflow := idx + size - a.length
	if overflow > 0 {
		lenbits := len(a.bits)
		freespace := (lenbits << 6) - a.length
		if overflow > freespace {
			a.bits = append(a.bits, 0)
		}
		a.length += overflow
	}
	bitIdx := idx & 63
	arrayIdx := idx >> 6
	lowBitSz := 64 - bitIdx
	overflow = size - lowBitSz
	ba := a.bits[arrayIdx]
	bb := bits << uint(bitIdx)
	mask := uint64(1<<uint(size)) - 1
	a.bits[arrayIdx] = ba ^ ((ba ^ bb) & (mask << uint(bitIdx)))
	if overflow > 0 {
		arrayIdx++
		ba = a.bits[arrayIdx]
		bb = bits >> uint(lowBitSz)
		a.bits[arrayIdx] = ba ^ ((ba ^ bb) & (mask >> uint(lowBitSz)))
	}
}