{"id":13458220,"url":"https://github.com/huandu/skiplist","last_synced_at":"2025-10-18T00:15:24.769Z","repository":{"id":3087466,"uuid":"4111775","full_name":"huandu/skiplist","owner":"huandu","description":"Fast and easy-to-use skip list for Go.","archived":false,"fork":false,"pushed_at":"2024-09-23T05:02:10.000Z","size":52,"stargazers_count":409,"open_issues_count":0,"forks_count":67,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-06T00:06:06.369Z","etag":null,"topics":["algortihm","database","go","hashmap","skiplist"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/huandu/skiplist","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huandu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-04-23T10:02:47.000Z","updated_at":"2025-04-04T14:19:37.000Z","dependencies_parsed_at":"2024-11-28T12:02:04.689Z","dependency_job_id":"6dffabd3-032b-40e5-8d2c-8fc1151a5a93","html_url":"https://github.com/huandu/skiplist","commit_stats":{"total_commits":33,"total_committers":9,"mean_commits":"3.6666666666666665","dds":0.6060606060606061,"last_synced_commit":"ceb3cd57cee003bd5f6c035b7506ca63d77fef10"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huandu%2Fskiplist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huandu%2Fskiplist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huandu%2Fskiplist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huandu%2Fskiplist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huandu","download_url":"https://codeload.github.com/huandu/skiplist/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654045,"owners_count":21140235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algortihm","database","go","hashmap","skiplist"],"created_at":"2024-07-31T09:00:47.794Z","updated_at":"2025-10-18T00:15:19.751Z","avatar_url":"https://github.com/huandu.png","language":"Go","funding_links":[],"categories":["Components","Awesome Algorithms","Go"],"sub_categories":["Vectors","SL - Skip List (跳跃列表)"],"readme":"# Skip List in Golang\n\n[![Go](https://github.com/huandu/skiplist/workflows/Go/badge.svg)](https://github.com/huandu/skiplist/actions)\n[![Go Doc](https://godoc.org/github.com/huandu/skiplist?status.svg)](https://pkg.go.dev/github.com/huandu/skiplist)\n[![Go Report](https://goreportcard.com/badge/github.com/huandu/skiplist)](https://goreportcard.com/report/github.com/huandu/skiplist)\n[![Coverage Status](https://coveralls.io/repos/github/huandu/skiplist/badge.svg?branch=master)](https://coveralls.io/github/huandu/skiplist?branch=master)\n\nSkip list is an ordered map. See wikipedia page [skip list](http://en.wikipedia.org/wiki/Skip_list) to learn algorithm details about this data structure.\n\nHighlights in this implementation:\n\n- Built-in types can be used as key with predefined key types. See [Int](https://pkg.go.dev/github.com/huandu/skiplist#Int) and related constants as a sample.\n- Support custom comparable function so that any type can be used as key.\n- Key sort order can be changed quite easily. See [Reverse](https://pkg.go.dev/github.com/huandu/skiplist#Reverse) and [LessThanFunc](https://pkg.go.dev/github.com/huandu/skiplist#LessThanFunc).\n- Rand source and max level can be changed per list. It can be useful in performance critical scenarios.\n\n## Install\n\nInstall this package through `go get`.\n\n```bash\n    go get github.com/huandu/skiplist\n```\n\n## Basic Usage\n\nHere is a quick sample.\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/huandu/skiplist\"\n)\n\nfunc main() {\n    // Create a skip list with int key.\n    list := skiplist.New(skiplist.Int)\n\n    // Add some values. Value can be anything.\n    list.Set(12, \"hello world\")\n    list.Set(34, 56)\n    list.Set(78, 90.12)\n\n    // Get element by index.\n    elem := list.Get(34)                // Value is stored in elem.Value.\n    fmt.Println(elem.Value)             // Output: 56\n    next := elem.Next()                 // Get next element.\n    prev := next.Prev()                 // Get previous element.\n    fmt.Println(next.Value, prev.Value) // Output: 90.12    56\n\n    // Or, directly get value just like a map\n    val, ok := list.GetValue(34)\n    fmt.Println(val, ok) // Output: 56  true\n\n    // Find first elements with score greater or equal to key\n    foundElem := list.Find(30)\n    fmt.Println(foundElem.Key(), foundElem.Value) // Output: 34 56\n\n    // Remove an element for key.\n    list.Remove(34)\n}\n```\n\n## Using `GreaterThanFunc` and `LessThanFunc`\n\nDefine your own `GreaterThanFunc` or `LessThanFunc` to use any custom type as the key in a skip list.\n\nThe signature of `GreaterThanFunc` are `LessThanFunc` are the same.\nThe only difference between them is that `LessThanFunc` reverses result returned by custom func\nto make the list ordered by key in a reversed order.\n\n```go\ntype T struct {\n    Rad float64\n}\nlist := New(GreaterThanFunc(func(k1, k2 interface{}) int {\n    s1 := math.Sin(k1.(T).Rad)\n    s2 := math.Sin(k2.(T).Rad)\n\n    if s1 \u003e s2 {\n        return 1\n    } else if s1 \u003c s2 {\n        return -1\n    }\n\n    return 0\n}))\nlist.Set(T{math.Pi / 8}, \"sin(π/8)\")\nlist.Set(T{math.Pi / 2}, \"sin(π/2)\")\nlist.Set(T{math.Pi}, \"sin(π)\")\n\nfmt.Println(list.Front().Value) // Output: sin(π)\nfmt.Println(list.Back().Value)  // Output: sin(π/2)\n```\n\n## License\n\nThis library is licensed under MIT license. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuandu%2Fskiplist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuandu%2Fskiplist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuandu%2Fskiplist/lists"}