kelindar / bitmap

Simple dense bitmap index in Go with binary operators
MIT License
306 stars 23 forks source link

support `not` operation #24

Open on99 opened 2 years ago

on99 commented 2 years ago

is it possible to support not operation? https://en.wikipedia.org/wiki/Bitwise_operation#NOT

chippyash commented 1 year ago

Not is fairly trivially implemented with

func Not(a bitmap.Bitmap) bitmap.Bitmap {
    var res bitmap.Bitmap
    a.Clone(&res)
    res.Ones()

    //rfunc clears bits in res if they are set in a
    rFunc := func(k uint32) {
        res.Remove(k)
    }

    a.Range(rFunc)
    return res
}
chippyash commented 1 year ago

The Not and other functions are implemented in https://github.com/chippyash/logicgate.git