Code Monkey home page Code Monkey logo

bitmap's Introduction

Bitmap

Yet another bitmap implementation written in go.

Installation

$ go get -v github.com/f1monkey/bitmap

Usage

func main() {
    var b bitmap.Bitmap64

    b.IsEmpty() // true

    b.Set(0)
    b.Has(0) // true
    b.Remove(0)
    b.Has(0) // false

    b.Xor(1000)
    b.Has(1000) // true
    b.Xor(1000)
    b.Has(1000) // false

    b2 := b.Clone() // copy of "b"

    b2.Range(func(n uint32) bool {
        fmt.PrintLn(n)
        return true
    })

    b.Or(b2) // in-place OR
    b.And(b2) // in-place AND

    // to string, from string
    var b3 bitmap.Bitmap64
    b3.Set(1)
    b3.Set(100)
    b3.String() // "2|68719476736"
    b4, err := bitmap.FromString("2|68719476736")

    // Bitmap32 is backed by []uint32 slice
    // Everything else is all the same
    var b32 bitmap.Bitmap32

    // Bitmap16 is backed by []uint16 slice
    // Everything else is all the same
    var b16 bitmap.Bitmap16

    // Bitmap8 is backed by []uint8 slice
    // Everything else is all the same
    var b8 bitmap.Bitmap8
}

bitmap's People

Contributors

cyradin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.