{"id":19659984,"url":"https://github.com/samyak2/skip-list","last_synced_at":"2025-06-24T10:33:43.839Z","repository":{"id":117920449,"uuid":"352932922","full_name":"Samyak2/skip-list","owner":"Samyak2","description":"C++ implementation of skip list compatible with STL","archived":false,"fork":false,"pushed_at":"2021-05-25T10:49:34.000Z","size":470,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-28T20:46:14.516Z","etag":null,"topics":["cpp","datastructure","skiplist","stl"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Samyak2.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-30T08:50:51.000Z","updated_at":"2024-08-09T20:40:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"d3ce9b5d-a590-47db-97a4-2608671a4a4d","html_url":"https://github.com/Samyak2/skip-list","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Samyak2/skip-list","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samyak2%2Fskip-list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samyak2%2Fskip-list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samyak2%2Fskip-list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samyak2%2Fskip-list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Samyak2","download_url":"https://codeload.github.com/Samyak2/skip-list/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samyak2%2Fskip-list/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259553130,"owners_count":22875609,"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":["cpp","datastructure","skiplist","stl"],"created_at":"2024-11-11T15:44:55.263Z","updated_at":"2025-06-13T00:07:24.284Z","avatar_url":"https://github.com/Samyak2.png","language":"C++","readme":"# skip-list\n\nC++ implementation of skip list compatible with STL.  \nDocumentation contains:\n1. [Usage](#usage) _(i.e. how to navigate this project)_\n2. [Examples](#examples) _(how to use skiplist in your own project)_\n3. [Reference](#reference) _(major interfaces)_\n\n## Usage\n1. Clone the repository `https://github.com/Samyak2/skip-list/` and `cd` into it\n2. To build all the sample binaries from the `example` folder: \n```bash\nmkdir build\ncd build\ncmake ..\nmake\n```\n\nThis will generate the sample binaries (`tester`, etc.)  \nThey act as test-cases, covering all major functionalities of skiplist.  \n\n### Running benchmarks\n\nRequirements:\n - Python 3\n - `matplotlib` -\u003e `python3 -m pip install matplotlib`\n\nThe benchmarking application generates graphs to visualize the time\ncomplexity of the algorithms of skiplist.  \nTo view them `cd` into `build` and then:\n\n```bash\ncmake..\nmake benchmarks\npython3 ../examples/benchmarks.py\n```\n\nThe graphs will be saved in the same `build` directory.\n\n## Examples\nFirst - copy the desired header file to your project's workspace.  \nThen, inlucde it like this - \n```cpp \n#include \"skiplist.hpp\"\n```  \nNow you have a `skiplist` container available. It has the same(almost) interface as a `multiset`.  \nHere is an example of using it with an integer:  \n```cpp\nskiplist\u003cint\u003e notaset;\nnotaset.insert(42);\nnotaset.insert(13);\nnotaset.insert(420);\n// can insert to the same key too\nnotaset.insert(420);\n\n// erasing items\nnotaset.erase(13);\n\n// finding items\nskiplist\u003cint\u003e::iterator it = notaset.find(42);\nif(it != notaset.end())\n    std::cout \u003c\u003c \"Could not find it\\n\";\nelse\n    std::cout \u003c\u003c *it;\n```  \n\nNote that skiplist is a canonical class, so all this is valid:\n```cpp\nskiplist\u003cstring\u003e a;\nskiplist\u003cstring\u003e b(a);\nskiplist\u003cstring\u003e c; c = a;\nskiplist\u003cstring\u003e d(move(b));\nskiplist\u003cstring\u003e e; e = move(c);\n```  \n\nGiven that it was designed with STL compaitability in mind, you can use it with your favourite algorithms!  \nNote that the iterator is a bidirectional one, it cannot make use of random access (YET!).  \n\n## Reference\nSkiplist is defined in `skiplist.hpp`:  \n```cpp\ntemplate\u003c\n    typename val_type,\n    typename compare_t = std::less\u003cval_type\u003e\n\u003e\nclass skiplist;\n```  \n`skiplist` is a sorted container, similar to `std::multiset`.   \nInternally it uses a Skip-list which is a\nsimpler alternative to a height balanced binary search tree.  \nSorting is done based on the `compare_t` functor class which by default uses `\u003c`.  \nMultiple elements with the same `val_type` (i.e. key value) are allowed \nand are accessed in the order they were inserted.  \nThis order does not change.\nFollowing the standard library, equivalence is defined as: `!comp(a, b) \u0026\u0026 !comp(b, a)`.  \nAll the classes within the header file are canonical classes.  \n\n### Multi-map\nThe header file `skiplist_map.hpp` has a map version of skiplist similar to `std::multimap`.  \nIt is defined as :  \n```cpp\ntemplate\u003c\n    typename key_type,\n    typename val_type,\n    typename compare_t = std::less\u003ckey_type\u003e\n\u003e\nclass skiplist;\n```\n\n### Member types (of iterator, not skiplist)\n* difference_type = std::ptrdiff_t;  \n* value_type = val_type;  \n* pointer = val_type*;  \n* reference = val_type\u0026;  \n* iterator_category = std::bidirectional_iterator_tag;  \n\n### Member functions\n* constructor -\u003e default, move, copy, from pair of iterators, initialization list\n* destructor\n* operator= -\u003e move, copy\n\n#### Iterators (All invalidated on a modify operation)\n* begin  \n  cbegin\n* end  \n  cend\n* rbegin  \n  crbegin\n* rend  \n  crend\n  \n#### Capacity\n* size() -\u003e Returns total number of elements in skiplist (including non-unique ones)\n\n#### Modifiers\n* insert(val_type) -\u003e insert an element in logarithmic time\n* erase(val_type / iterator) -\u003e remove an element in logarithmic time\n\n#### Lookup\n* count(val_type) -\u003e return number of elements matching a specific key\n* find(val_type) -\u003e finds an element in logarithmic time\n\n### Non-member functions\n* operator\u003c\u003c -\u003e prints out the skip list level by level\n\n### Notes\nLike other sorted associative containers a skiplist's iterators are just aliases to its constant iterators.  \nISSUES - Please open a new one on the GitHub repo  \nBUG REPORTS - Write it in a file `bug-report.txt` and send it to `/dev/null`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamyak2%2Fskip-list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamyak2%2Fskip-list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamyak2%2Fskip-list/lists"}