go- Bitmap

type BitMap struct {
    bytes []byte
    nbits int
}

func(bm *BitMap)set(k int){
    if k>bm.nbits {
        return
    }
    byteIndex := k/8 

8 // go because the byte 1 byte or 8 bits
    bitIndex: = uint (8% K)
    bm.bytes [byteIndex] | = <<. 1 bitIndex
}
FUNC (BM * the BitMap) GET (int K) {BOOL
    IF K> bm.nbits {
        return to false
    }
    byteIndex: K = /. 8
    bitIndex: K =. 8%
    return bm.bytes [byteIndex] <<. 1 & uint (bitIndex) = 0!
}

Guess you like

Origin blog.csdn.net/u013755520/article/details/92079434