{"id":21570588,"url":"https://github.com/jcash/containers","last_synced_at":"2025-06-27T15:06:59.756Z","repository":{"id":46114713,"uuid":"53367015","full_name":"JCash/containers","owner":"JCash","description":"A collection of containers that I use","archived":false,"fork":false,"pushed_at":"2024-12-28T10:50:11.000Z","size":15712,"stargazers_count":56,"open_issues_count":1,"forks_count":4,"subscribers_count":6,"default_branch":"dev","last_synced_at":"2025-06-27T15:04:33.235Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","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/JCash.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":"2016-03-07T23:35:51.000Z","updated_at":"2025-06-03T11:00:33.000Z","dependencies_parsed_at":"2025-04-10T14:13:15.295Z","dependency_job_id":"7e640191-1674-4928-a07b-557564b07fed","html_url":"https://github.com/JCash/containers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JCash/containers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCash%2Fcontainers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCash%2Fcontainers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCash%2Fcontainers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCash%2Fcontainers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JCash","download_url":"https://codeload.github.com/JCash/containers/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCash%2Fcontainers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262279099,"owners_count":23286547,"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-11-24T11:13:11.233Z","updated_at":"2025-06-27T15:06:59.735Z","avatar_url":"https://github.com/JCash.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"| Build Status | macOS / Linux / Windows   |\n|--------------|---------------------------|\n|master        | [![Build Status](https://github.com/jcash/containers/workflows/Build/badge.svg?branch=master)](https://github.com/JCash/containers/actions?query=branch%3Amaster) |\n|dev           | [![Build Status](https://github.com/jcash/containers/workflows/Build/badge.svg?branch=dev)](https://github.com/JCash/containers/actions?query=branch%3Adev) |\n\n\n\n# Containers\n\nA collection of header only containers that I use\n\n# Disclaimer\n\nThis software is supplied \"AS IS\" without any warranties and support\n\n# License\n\n[The MIT license](http://choosealicense.com/licenses/mit/)\n\n## [jc::HashTable](src/jc/hashtable.h)\n\nA fast and small C++ implementation of a hash table\n\n* ~260 lines of code\n* Open addressing\n* Robin Hood collision resolving\n* Backward shift deletion\n* On par with Google's dense_hash_map\n\n## [jc/algorithm](src/jc/algorithm.h)\n\nThe jc::lower_bound and jc::upper_bound are about 1.6x - 2.3x faster than their STL counter parts.\n\n## [jc::radix_sort](src/jc/sort.h)\n\nThe radix sort is a stable sort, which requires an output buffer of the same length.\nIt is ~70 lines of code.\nIt is 12%-25% faster than [ska::sort](https://github.com/skarupke/ska_sort)\n\n## [jc::Array](src/jc/array.h)\n\nA fast and small C++ container for storing dynamic arrays.\n\n* ~140 lines of code\n* ~3x faster than std::vector, and ~2x faster than eastl::vector when using \"push_back\"\n* Otherwise same performance as the others\n\n## [jc::BitArray](src/jc/bitarray.h)\n\n* Header only C/C++ bit array\n## [jc::RingBuffer](src/jc/ringbuffer.h)\n\nA small C++ ring buffer\n\n* ~120 lines of code\n* Can be resized (using realloc and copying items)\n\n# [Benchmarks](benchmarks/README.md)\n\n*See [benchmark page](benchmarks/README.md) for more stats.*\n\nPerformance examples for jc::HashTable.\n\u003cbr/\u003e\n\u003cimg src=\"./benchmarks/images/timings_insert_random_sizeof(value)==152.png\" alt=\"Timings insert_random size=152\" width=\"350\"\u003e\n\u003cimg src=\"./benchmarks/images/timings_get_random_sizeof(value)==152.png\" alt=\"Timings get_random size=152\" width=\"350\"\u003e\n\nPerformance examples for jc::Array.(See benchmark page for more stats)\n\u003cbr/\u003e\n\u003cimg src=\"./benchmarks/images/array/timings_get_random_small.png\" alt=\"Timings get_random size=8\" width=\"350\"\u003e\n\u003cimg src=\"./benchmarks/images/array/timings_push_back.png\" alt=\"Timings push_back size=8\" width=\"350\"\u003e\n\n\n# Usage\n\n## jc::HashTable\n\n    struct SPod\n    {\n        int     i;\n        float   f;\n    };\n    typedef jc::HashTable\u003cuint32_t, SPod\u003e hashtable_t;\n\n    uint32_t numelements    = 1000; // The maximum number of entries to store\n    uint32_t load_factor    = 85; // percent\n    uint32_t tablesize      = uint32_t(numelements / (load_factor/100.0f));\n    uint32_t sizeneeded     = hashtable_t::CalcSize(tablesize);\n\n    void* mem = malloc(sizeneeded);\n\n    hashtable_t ht;\n    ht.Create(numelements, mem);\n\n    SPod value = { 1, 2.0f };\n    ht.Put(17, value);\n\n    Spod* pval = ht.Get(17);\n    assert( pval-\u003ei == 1 );\n    assert( pval-\u003ef == 2.0f );\n\n    hashtable_t it = ht.Begin();\n    hashtable_t itend = ht.End();\n    for(; it != itend; ++it)\n    {\n        printf(\"key: %u  value: %d, %f\\n\", *it.GetKey(), it.GetValue()-\u003ei, it.GetValue()-\u003ef);\n    }\n\n    ht.Erase(17);\n\n    free(mem);\n\n\n## jc::Array\n\n    #include \u003cjc/array.h\u003e\n\n    jc::Array\u003cint\u003e a;\n    a.SetCapacity(4);\n    for(size_t i = 0; i \u003c a.Capacity(); ++i)\n        a.Push(i);\n\n    a.EraseSwap(0); // 0,1,2,3 -\u003e 3,1,2\n\n    size_t sum = 0;\n    for(size_t i = 0; i \u003c a.Size(); ++i)\n        sum += a[i];\n\n## jc::RingBuffer\n\n    #include \u003cjc/ringbuffer.h\u003e\n\n    jc::RingBuffer\u003cint\u003e a;\n    a.SetCapacity(4);\n    for(size_t i = 0; i \u003c a.Capacity(); ++i)\n        a.Push(i);\n    // [0,1,2,3]\n\n    print(\"%d\", a.Pop()); // -\u003e 0\n    // [1,2,3]\n\n    a.Push(4);\n    // [1,2,3,4]\n\n    // Buffer is full.\n    // Either increase size...\n    if (a.Full())\n        a.SetCapacity(6);\n    // [1,2,3,4]\n\n    a.Push(5);\n    a.Push(6);\n    // [1,2,3,4,5,6]\n\n    // ... or, if full again, use the PushUnchecked()\n    a.PushUnchecked(7);\n    // [2,3,4,5,6,7]\n\n    // Loop over the items\n    for(int i = 0; i \u003c a.Size(); ++i)\n        print(\"%d\", a[i]);","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcash%2Fcontainers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcash%2Fcontainers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcash%2Fcontainers/lists"}