Skip to content

FilWisher/lexi-int

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

lexi-int

Lexicographical ordering for integers. Produces []byte and hex string encodings of integers that maintain the same ordering before and after encoding.

From the implementation by substack.

example

import (
    lexi "github.com/filwisher/lexi-int"
)

func property(a, b uint32) bool {

    astr := lexi.PackHex(uint(a))
    bstr := lexi.PackHex(uint(b))

    if a < b {
        return astr < bstr
    } else if a > b {
        return astr > bstr
    } else {
        return astr == bstr
    }
}

methods

lexi.Pack(uint) []byte

lexi.Unpack([]byte) (uint, error)

lexi.PackHex(uint) string

lexi.UnpackHex(string) (uint, error)

install

$ go get https://github.com/substack/lexicographic-integer

About

Lexicographically ordered encodings of integers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages