{"id":13411726,"url":"https://github.com/gansidui/skiplist","last_synced_at":"2025-03-14T17:31:04.304Z","repository":{"id":23454715,"uuid":"26818585","full_name":"gansidui/skiplist","owner":"gansidui","description":"skiplist for golang","archived":false,"fork":false,"pushed_at":"2014-11-21T05:13:52.000Z","size":115,"stargazers_count":84,"open_issues_count":1,"forks_count":24,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-07-31T20:48:41.289Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"MassTransit/MassTransit","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gansidui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-18T16:29:53.000Z","updated_at":"2024-07-09T09:48:52.000Z","dependencies_parsed_at":"2022-08-29T11:21:37.540Z","dependency_job_id":null,"html_url":"https://github.com/gansidui/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/gansidui%2Fskiplist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gansidui%2Fskiplist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gansidui%2Fskiplist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gansidui%2Fskiplist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gansidui","download_url":"https://codeload.github.com/gansidui/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":[],"created_at":"2024-07-30T20:01:16.219Z","updated_at":"2025-03-14T17:31:04.046Z","avatar_url":"https://github.com/gansidui.png","language":"Go","readme":"skiplist\n===============\n\nreference from redis [zskiplist](https://github.com/antirez/redis)\n\n\nUsage\n===============\n\n~~~Go\n\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/gansidui/skiplist\"\n\t\"log\"\n)\n\ntype User struct {\n\tscore float64\n\tid    string\n}\n\nfunc (u *User) Less(other interface{}) bool {\n\tif u.score \u003e other.(*User).score {\n\t\treturn true\n\t}\n\tif u.score == other.(*User).score \u0026\u0026 len(u.id) \u003e len(other.(*User).id) {\n\t\treturn true\n\t}\n\treturn false\n}\n\nfunc main() {\n\tus := make([]*User, 7)\n\tus[0] = \u0026User{6.6, \"hi\"}\n\tus[1] = \u0026User{4.4, \"hello\"}\n\tus[2] = \u0026User{2.2, \"world\"}\n\tus[3] = \u0026User{3.3, \"go\"}\n\tus[4] = \u0026User{1.1, \"skip\"}\n\tus[5] = \u0026User{2.2, \"list\"}\n\tus[6] = \u0026User{3.3, \"lang\"}\n\n\t// insert\n\tsl := skiplist.New()\n\tfor i := 0; i \u003c len(us); i++ {\n\t\tsl.Insert(us[i])\n\t}\n\n\t// traverse\n\tfor e := sl.Front(); e != nil; e = e.Next() {\n\t\tfmt.Println(e.Value.(*User).id, \"--\u003e\", e.Value.(*User).score)\n\t}\n\tfmt.Println()\n\n\t// rank\n\trank1 := sl.GetRank(\u0026User{2.2, \"list\"})\n\trank2 := sl.GetRank(\u0026User{6.6, \"hi\"})\n\tif rank1 != 6 || rank2 != 1 {\n\t\tlog.Fatal()\n\t}\n\tif e := sl.GetElementByRank(2); e.Value.(*User).score != 4.4 || e.Value.(*User).id != \"hello\" {\n\t\tlog.Fatal()\n\t}\n}\n\n/* output:\n\nhi --\u003e 6.6\nhello --\u003e 4.4\nlang --\u003e 3.3\ngo --\u003e 3.3\nworld --\u003e 2.2\nlist --\u003e 2.2\nskip --\u003e 1.1\n\n*/\n\n~~~\n\n\nLicense\n===============\n\nMIT","funding_links":[],"categories":["Data Structures and Algorithms","Data Structures","数据结构与算法","数据结构","數據結構","Database","Data Integration Frameworks","数据结构`go语言实现的数据结构与算法`","Uncategorized","\u003cspan id=\"数据结构-data-structures\"\u003e数据结构 Data Structures\u003c/span\u003e","Generators"],"sub_categories":["Trees","Advanced Console UIs","树","高级控制台界面","高級控制台界面","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","标准 CLI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgansidui%2Fskiplist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgansidui%2Fskiplist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgansidui%2Fskiplist/lists"}