Skip to content

The implementation of Wavelet-Matrix in Go.

Notifications You must be signed in to change notification settings

gravity-im/go-waveletmatrix

 
 

Repository files navigation

waveletmatrix

Godoc Build Status Coverage Status

Description

The Wavelet Matrix implementation for Go..

Usage

package main

import (
    "fmt"

    "github.com/hideo55/go-waveletmatrix"
)

func main() {
    src := []uint64{1, 3, 1, 4, 2, 1, 10}
    wm, err := waveletmatrix.NewWM(src)
    if err != nil {
        // Failed to build wavelet-matrix
    }
    val, _ := wm.Lookup(3) 
    fmt.Println(val) // 4 ... src[3]
    rank, _ := wm.Rank(2, 6) 
    fmt.Println(rank) // 1 ... The number of 2 in src[0, 6)
    ranklt := wm.RankLessThan(3, 6)
    fmt.Println(ranklt) /// 4 ... The frequency of characters c' < c in src[0, 6)
    rankmt := wm.RankMoreThan(3, 6)
    fmt.Println(rankmt) /// 1 ... The frequency of characters c' > c in the src[0, 6)
    pos, _ := wm.Select(1, 3) // = 5 ... The third 1 appeared in src[5]
    fmt.Println(pos)
}

Supported version

Go 1.4 or later

License

MIT License

About

The implementation of Wavelet-Matrix in Go.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%