Skip to content

Latest commit

 

History

History
52 lines (40 loc) · 1.41 KB

README.md

File metadata and controls

52 lines (40 loc) · 1.41 KB

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