Socket
Book a DemoInstallSign in
Socket

xojoc.pw/bitset

Package Overview
Dependencies
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xojoc.pw/bitset

Go Modules
Version
v0.0.0-20200116205324-73c7a76a52a4
Version published
Created
Source

BitSet data structure

bitset is a library written in golang implementing a BitSet data structure.

Usage

First install the library with

go get xojoc.pw/bitset

...then run...

go test

if something fails open an issue.

As an example let's list all the composite numbers below 10:

package main

import (
	"fmt"
	"xojoc.pw/bitset"
)

func main() {
        c := &bitset.BitSet{}
        // Set all prime numbers to true.
        c.Set(2)
        c.Set(3)
        c.Set(5)
        c.Set(7)
        c.ToggleRange(1,10+1)
        for i := 1; i < c.Len(); i++ {
                if c.Get(i) {
                        fmt.Printf("%d is composite\n", i)
                }
        }
}

Output:

1 is composite
4 is composite
6 is composite
8 is composite
9 is composite
10 is composite

see godoc for the complete documentation.

Why?

Also see why use xojoc.pw/bitset and not math/big.

Who?

bitset was written by Alexandru Cojocaru.

Donate!

License

bitset is Free Software and in the Public Domain. No warranty.

FAQs

Package last updated on 16 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts