A Skip List Implementation Using "Go".
Go Shell
Switch branches/tags
Nothing to show
Pull request Compare This branch is 1 commit ahead, 7 commits behind huandu:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.textile
element.go
gen_compare_funcs.sh
skiplist.go
skiplist_test.go
type.go
var.go

README.textile

A golang Skip List Implementation.

This is a typical skip list implementation using go. It is a kind of ordered set and can store any value inside.

See Skip List wikipedia page for more information about this data structure.

How To Use

Here is a quick tutorial to show how easy to use it.

import "github.com/huandu/skiplist"

func main() {
    // create a list with int key
    // most built-in sortable type is supported
    // see "go doc" for more details
    list := skiplist.New(skiplist.Int)

    // add some values
    list.Set(12, "hello world")
    list.Set(34, 56)

    // get element
    elem := list.Get(34) // value is stored in elem.Value
    next := elem.Next()  // get next element

    // or get value directly just like using a map
    val, ok := list.GetValue(34)

    // remove an element
    list.Remove(34)
}

Use go doc to see usage and more docs.

go doc github.com/huandu/skiplist