{"id":13411722,"url":"https://github.com/MauriceGit/skiplist","last_synced_at":"2025-03-14T17:31:04.476Z","repository":{"id":33692396,"uuid":"138414869","full_name":"MauriceGit/skiplist","owner":"MauriceGit","description":"A Go library for an efficient implementation of a skip list: https://godoc.org/github.com/MauriceGit/skiplist","archived":false,"fork":false,"pushed_at":"2023-01-31T18:08:41.000Z","size":390,"stargazers_count":276,"open_issues_count":5,"forks_count":38,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-07-31T20:48:43.033Z","etag":null,"topics":["data-structures","go","golang","golang-library","skiplist"],"latest_commit_sha":null,"homepage":"","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/MauriceGit.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}},"created_at":"2018-06-23T16:01:51.000Z","updated_at":"2024-07-09T09:50:52.000Z","dependencies_parsed_at":"2023-02-16T22:00:26.752Z","dependency_job_id":null,"html_url":"https://github.com/MauriceGit/skiplist","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MauriceGit%2Fskiplist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MauriceGit%2Fskiplist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MauriceGit%2Fskiplist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MauriceGit%2Fskiplist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MauriceGit","download_url":"https://codeload.github.com/MauriceGit/skiplist/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243618657,"owners_count":20320272,"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":["data-structures","go","golang","golang-library","skiplist"],"created_at":"2024-07-30T20:01:16.175Z","updated_at":"2025-03-14T17:31:04.098Z","avatar_url":"https://github.com/MauriceGit.png","language":"Go","funding_links":[],"categories":["Data Integration Frameworks","Data Structures and Algorithms","数据结构与算法","Generators","Uncategorized","Data Structures","数据结构`go语言实现的数据结构与算法`","数据结构"],"sub_categories":["Trees","树","Advanced Console UIs","标准 CLI"],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/mauricegit/skiplist)](https://goreportcard.com/report/github.com/mauricegit/skiplist)\n [![cover.run](https://cover.run/go/github.com/MauriceGit/skiplist.svg?style=flat\u0026tag=golang-1.10)](https://cover.run/go?tag=golang-1.10\u0026repo=github.com%2FMauriceGit%2Fskiplist) \n\n## Fast Skiplist Implementation\n\nThis Go-library implements a very fast and efficient Skiplist that can be used as direct substitute for a balanced tree or linked list.\nAll basic operations ( `Find`, `Insert` and `Delete`) have approximate runtimes of O(log(n)) that prove real in benchmarks.\n\nFor detailed API documentation, see the official docs: [godoc.org/github.com/MauriceGit/skiplist](https://godoc.org/github.com/MauriceGit/skiplist).\n\nThis implementation introduces a minimum amount of overhead and is tailored for maximum performance across all operations.\nIn benchmarks, this skiplist is currently the fastest implementation in Go known to me.\nSee a thorough benchmark of multiple skiplist implementations at: [github.com/MauriceGit/skiplist-survey](https://github.com/MauriceGit/skiplist-survey).\n\n### `Find`, `Insert`, `Delete` at both ends of the SkipList\n\n*Y-Axis is measured in nanoseconds per operation for all charts*\n\n![Find, Insert, Delete](graphs/allFunctions.png)\nAll functions, be it `Find`, `Insert` or `Delete` that operate on first or last elements in the skiplist behave in near Constant time, no matter how many\nelements are already inserted in the skiplist.\n\n![Random insert, random delete](graphs/randomFunctions.png)\nFor real-world cases where elements are inserted or removed at random positions in the skiplist, we can clearly see the approximate O(log(n)) behaviour of the\nimplementation which approximates to a constant value around 1800ns for `Delete` and 2200ns for `Insert`.\n\n### Comparison to other Skiplist implementations\n\nThe following graphs are taken from [github.com/MauriceGit/skiplist-survey](https://github.com/MauriceGit/skiplist-survey). Please visit this skiplist survey for\na much more detailed comparison over several benchmarks between different skiplist implementations.\n\nOverall, this implementation is the fastest skiplist for nearly all operations. Especially for real-world applications.\n\n![Random insert](graphs/randomInserts.png)\nIf we compare random insertions of this skiplist to other implementations, it is clearly the fastest by up to 800ns per insertion for up to 3m elements.\n\n![Random delete](graphs/randomDelete.png)\nIf we compare random deletions of this skiplist to other implementations, it is clearly the fastest by up to 300ns per deletion for up to 3m elements.\n\n### Usage\n\n```go\n\nimport (\n    \"github.com/MauriceGit/skiplist\"\n    \"fmt\"\n)\n\ntype Element int\n// Implement the interface used in skiplist\nfunc (e Element) ExtractKey() float64 {\n    return float64(e)\n}\nfunc (e Element) String() string {\n    return fmt.Sprintf(\"%03d\", e)\n}\n\nfunc main() {\n    list := New()\n\n    // Insert some elements\n    for i := 0; i \u003c 100; i++ {\n        list.Insert(Element(i))\n    }\n\n    // Find an element\n    if e, ok := list.Find(Element(53)); ok {\n        fmt.Println(e)\n    }\n\n    // Delete all elements\n    for i := 0; i \u003c 100; i++ {\n        list.Delete(Element(i))\n    }\n}\n\n```\n\n### Convenience functions\n\nOther than the classic `Find`, `Insert` and `Delete`, some more convenience functions are implemented that makes this skiplist implementation very easy and straight forward to use\nin real applications. All complexity values are approximates, as skiplist can only approximate runtime complexity.\n\n| Function        | Complexity           | Description  |\n| ------------- |:-------------:|:-----|\n| Find | O(log(n)) | Finds an element in the skiplist |\n| FindGreaterOrEqual | O(log(n)) | Finds the first element that is greater or equal the given value in the skiplist |\n| Insert | O(log(n)) | Inserts an element into the skiplist |\n| Delete | O(log(n)) | Deletes an element from the skiplist |\n| GetSmallestNode | O(1) | Returns the smallest element in the skiplist |\n| GetLargestNode | O(1) | Returns the largest element in the skiplist |\n| Prev | O(1) | Given a skiplist-node, it returns the previous element (Wraps around and allows to linearly iterate the skiplist) |\n| Next | O(1) | Given a skiplist-node, it returns the next element (Wraps around and allows to linearly iterate the skiplist) |\n| ChangeValue | O(1) | Given a skiplist-node, the actual value can be changed, as long as the key stays the same (Example: Change a structs data) |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMauriceGit%2Fskiplist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMauriceGit%2Fskiplist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMauriceGit%2Fskiplist/lists"}