Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Skip List Implementation Using "Go".

branch: master
README.textile

A golang Skip List Implementation.

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

See Skip List wikipedia page to learn more 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
Something went wrong with that request. Please try again.