con
github.com/acedarkknight/concurrentskiplist
go get github.com/acedarkknight/concurrentskiplist
con

github.com/acedarkknight/concurrentskiplist

A light, high-performance, concurrent, thread-safe skip list implementation written in Golang.

go get github.com/acedarkknight/concurrentskiplist
Readme

ConcurrentSkipList

Build Status Maintainability license Coverage Status Go Report Card

A light, high-performance, concurrent, thread-safe skip list implementation written in Golang.

Getting Start

  • Import package
go get github.com/AceDarkknight/ConcurrentSkipList
import "github.com/AceDarkknight/ConcurrentSkipList"
  • Usage
// Create a new skip list. The parameter is the level of the skip list.
// Parameter must > 0 and <=32, if not, err is not nil.
skipList, err := ConcurrentSkipList.NewConcurrentSkipList(12)
if err != nil {
    fmt.Println(err)
}

// Insert index and value. The index must uint64 and value is interface.
skipList.Insert(uint64(1), 1)
skipList.Insert(uint64(2), 2)

// Search in skip list.
if node, ok := skipList.Search(uint64(1)); ok {
    fmt.Printf("index:%v value:%v\n", node.Index(), node.Value())
}

// Delete by index.
skipList.Delete(uint64(2))

// Get the level of skip list.
_ = skipList.Level()

// Get the length of skip list.
_ = skipList.Length()

// Iterate each node in skip list.
skipList.ForEach(func(node *ConcurrentSkipList.Node) bool {
    fmt.Printf("index:%v value:%v\n", node.Index(), node.Value())
    return true
})

// Select top 10 nodes of skip list.
nodes := skipList.Sub(0, 10)

TODO

  • Reduce memory.
  • Add reverse operation.

References

https://en.wikipedia.org/wiki/Skip_list

GitHub Stars

11

LAST COMMIT

2yrs ago

MAINTAINERS

0

CONTRIBUTORS

2

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
v0.0.0-20201026075402-347c1f2b9242
2yrs ago
v0.0.0-20180423121926-791eedc718e0
3yrs ago
No alternatives found
No tutorials found
Add a tutorial