{"id":15049502,"url":"https://github.com/garfield1002/jrsl","last_synced_at":"2026-03-17T21:31:45.892Z","repository":{"id":47307433,"uuid":"402834013","full_name":"Garfield1002/jrsl","owner":"Garfield1002","description":"A C/C++ implementation of William Pugh's Skip Lists with width","archived":false,"fork":false,"pushed_at":"2021-09-04T12:28:35.000Z","size":31,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-20T21:17:52.480Z","etag":null,"topics":["c","c89","cpp","library","public-domain","single-header-lib","skiplist"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Garfield1002.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":"2021-09-03T16:31:37.000Z","updated_at":"2024-06-12T18:51:34.000Z","dependencies_parsed_at":"2022-09-08T01:11:34.760Z","dependency_job_id":null,"html_url":"https://github.com/Garfield1002/jrsl","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/Garfield1002%2Fjrsl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Garfield1002%2Fjrsl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Garfield1002%2Fjrsl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Garfield1002%2Fjrsl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Garfield1002","download_url":"https://codeload.github.com/Garfield1002/jrsl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243510127,"owners_count":20302294,"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":["c","c89","cpp","library","public-domain","single-header-lib","skiplist"],"created_at":"2024-09-24T21:20:58.825Z","updated_at":"2025-12-29T21:38:04.338Z","avatar_url":"https://github.com/Garfield1002.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C/C++ Skip List Implementation\n\nThis is C89 implementation of the data type described in [William Pugh's paper](https:www.epaperpress.com/sortsearch/download/skiplist.pdf) with widths.\n\n\u003e Skip lists are a data structure that can be used in place of balanced trees.\n\u003e Skip lists use probabilistic balancing rather than strictly enforced balancing\n\u003e and as a result the algorithms for insertion and deletion in skip lists are\n\u003e much simpler and significantly faster than equivalent algorithms for\n\u003e balanced trees.\n\nUsing widths allows for efficient random access.\n\nAlthough this library will work with C and C++, if you perfer fancy C++ objects you can check out [my first implementation of skip lists](https://github.com/Garfield1002/jhr_skip_list)\n\n## 💡 Why use Skip Lists ?\n\nSkip Lists allow insertion, deletion, random access and search in O(log n) on average (and O(n) in worst case).\nSkip lists are a simple data structure that can be used in place of balanced trees for most applications and are much less daunting.\n\n## 📚 Usage\n\n**This library is written in standard C89 for portability.**\n\nThe idea behind single-header file libraries is that they're easy to distribute and deploy because all the code is contained in a single file.\nThe .h file acts as its own header files, i.e. it declares the functions and classes contained in the file but no code is getting compiled.\n\nSo in addition, you should select _exactly_ one C/C++ source file that actually instantiates the code, preferably a file you're not editing frequently.\nThis file should define `JRSL_IMPLEMENTATION` to actually enable the function definitions.\n\nYou can check out [example.c](https://github.com/Garfield1002/jrsl/blob/master/example/example.c) for some sample code.\n\n### Skip List Methods\n\n---\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003eFunction\u003c/th\u003e\n    \u003cth\u003eEffect\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd colspan=\"2\"\u003e\n        \u003cb\u003eCreation and deletion\u003c/b\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003ejrsl_initialize()\u003c/td\u003e\n    \u003ctd\u003eInitializes a skip list\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003ejrsl_destroy()\u003c/td\u003e\n    \u003ctd\u003eCleans up a skip list\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd colspan=\"2\"\u003e\n        \u003cb\u003eSize and capacity\u003c/b\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003ejrsl_max_level()\u003c/td\u003e\n    \u003ctd\u003eCalculates the optimal maximum for the amount of levels\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd colspan=\"2\"\u003e\n        \u003cb\u003eElement access\u003c/b\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003ejrsl_data_at()\u003c/td\u003e\n    \u003ctd\u003eReturns the data at a particular index\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\u003c/tr\u003e\n    \u003ctr\u003e\n    \u003ctd\u003ejrsl_key_at()\u003c/td\u003e\n    \u003ctd\u003eReturns the key at a particular index\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd colspan=\"2\"\u003e\n        \u003cb\u003eModification\u003c/b\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003ejrsl_insert()\u003c/td\u003e\n    \u003ctd\u003eInserts an element (a key and some data) in the skip list and returns `NULL`\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003ejrsl_remove()\u003c/td\u003e\n    \u003ctd\u003eRemoves an element from the skip list, deletes the key and returns it's data\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd colspan=\"2\"\u003e\n        \u003cb\u003eSearching\u003c/b\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003ejrsl_search()\u003c/td\u003e\n    \u003ctd\u003eReturns the data of the node with a given key\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd colspan=\"2\"\u003e\n        \u003cb\u003eVisualization\u003c/b\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003ejrsl_display_list()\u003c/td\u003e\n    \u003ctd\u003ePrints a visual representation of the skip list\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## ⭐ Contribution\n\nAll contributions are welcome!\n\n## ⚖ License\n\nThis library is in the public domain. You can do anything you want with it. You have no legal obligation to do anything else, although I appreciate attribution.\n\nIt is also licensed under the MIT open source license, if you have lawyers who are unhappy with public domain. The source file includes an explicit dual-license for you to choose from.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarfield1002%2Fjrsl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgarfield1002%2Fjrsl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarfield1002%2Fjrsl/lists"}