func (b *BitSet) DeleteAt(i uint) *BitSet {
	deleteAtElement := i >> log2WordSize
	dataMask := ^((uint64(1) << (i & (wordSize - 1))) - 1)
	data := b.set[deleteAtElement] & dataMask
	b.set[deleteAtElement] &= ^dataMask
	b.set[deleteAtElement] |= (data >> 1) & dataMask
	for i := int(deleteAtElement) + 1; i < len(b.set); i++ {
		b.set[i-1] |= (b.set[i] & 1) << 63
		b.set[i] >>= 1
	}
	b.length = b.length - 1
	return b
}
DeleteAt deletes the bit at the given index position from
within the bitset
All the bits residing on the left of the deleted bit get
shifted right by 1
The running time of this operation may potentially be
relatively slow, O(length)
package bitset
import (
	"bufio"
	"bytes"
	"encoding/base64"
	"encoding/binary"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"strconv"
)
const wordSize = uint(64)
const log2WordSize = uint(6)
const allBits uint64 = 0xffffffffffffffff
var binaryOrder binary.ByteOrder = binary.BigEndian
var base64Encoding = base64.URLEncoding
func Base64StdEncoding() { base64Encoding = base64.StdEncoding }
func LittleEndian() { binaryOrder = binary.LittleEndian }
type BitSet struct {
	length uint
	set    []uint64
}
type Error string
func (b *BitSet) safeSet() []uint64 {
	if b.set == nil {
		b.set = make([]uint64, wordsNeeded(0))
	}
	return b.set
}
func From(buf []uint64) *BitSet {
	return &BitSet{uint(len(buf)) * 64, buf}
}
func (b *BitSet) Bytes() []uint64 {
	return b.set
}
func wordsNeeded(i uint) int {
	if i > (Cap() - wordSize + 1) {
		return int(Cap() >> log2WordSize)
	}
	return int((i + (wordSize - 1)) >> log2WordSize)
}
func New(length uint) (bset *BitSet) {
	defer func() {
		if r := recover(); r != nil {
			bset = &BitSet{
				0,
				make([]uint64, 0),
			}
		}
	}()
	bset = &BitSet{
		length,
		make([]uint64, wordsNeeded(length)),
	}
	return bset
}
func Cap() uint {
	return ^uint(0)
}
func (b *BitSet) Len() uint {
	return b.length
}
func (b *BitSet) extendSetMaybe(i uint) {
	if i >= b.length {  
		nsize := wordsNeeded(i + 1)
		if b.set == nil {
			b.set = make([]uint64, nsize)
		} else if cap(b.set) >= nsize {
			b.set = b.set[:nsize]  
		} else if len(b.set) < nsize {
			newset := make([]uint64, nsize, 2*nsize)  
			copy(newset, b.set)
			b.set = newset
		}
		b.length = i + 1
	}
}
func (b *BitSet) Test(i uint) bool {
	if i >= b.length {
		return false
	}
	return b.set[i>>log2WordSize]&(1<<(i&(wordSize-1))) != 0
}
func (b *BitSet) Set(i uint) *BitSet {
	b.extendSetMaybe(i)
	b.set[i>>log2WordSize] |= 1 << (i & (wordSize - 1))
	return b
}
func (b *BitSet) Clear(i uint) *BitSet {
	if i >= b.length {
		return b
	}
	b.set[i>>log2WordSize] &^= 1 << (i & (wordSize - 1))
	return b
}
func (b *BitSet) SetTo(i uint, value bool) *BitSet {
	if value {
		return b.Set(i)
	}
	return b.Clear(i)
}
func (b *BitSet) Flip(i uint) *BitSet {
	if i >= b.length {
		return b.Set(i)
	}
	b.set[i>>log2WordSize] ^= 1 << (i & (wordSize - 1))
	return b
}
func (b *BitSet) Shrink(length uint) *BitSet {
	idx := wordsNeeded(length + 1)
	if idx > len(b.set) {
		return b
	}
	shrunk := make([]uint64, idx)
	copy(shrunk, b.set[:idx])
	b.set = shrunk
	b.length = length + 1
	b.set[idx-1] &= (allBits >> (uint64(64) - uint64(length&(wordSize-1)) - 1))
	return b
}
func (b *BitSet) InsertAt(idx uint) *BitSet {
	insertAtElement := (idx >> log2WordSize)
	if b.isLenExactMultiple() {
		b.set = append(b.set, uint64(0))
	}
	var i uint
	for i = uint(len(b.set) - 1); i > insertAtElement; i-- {
		b.set[i] <<= 1
		b.set[i] |= (b.set[i-1] & 0x8000000000000000) >> 63
	}
	dataMask := ^(uint64(1)<<uint64(idx&(wordSize-1)) - 1)
	data := b.set[i] & dataMask
	b.set[i] &= ^dataMask
	b.set[i] |= data << 1
	b.length++
	return b
}
func (b *BitSet) String() string {
	var buffer bytes.Buffer
	start := []byte("{")
	buffer.Write(start)
	counter := 0
	i, e := b.NextSet(0)
	for e {
		counter = counter + 1
		if counter > 0x40000 {
			buffer.WriteString("...")
			break
		}
		buffer.WriteString(strconv.FormatInt(int64(i), 10))
		i, e = b.NextSet(i + 1)
		if e {
			buffer.WriteString(",")
		}
	}
	buffer.WriteString("}")
	return buffer.String()
}