{"id":37441803,"url":"https://github.com/kothar/compactlist","last_synced_at":"2026-01-16T06:45:25.950Z","repository":{"id":27786763,"uuid":"114553578","full_name":"kothar/compactlist","owner":"kothar","description":"An efficient in-memory implementation of List\u003cLong\u003e aiming for minimum memory usage and good insert/remove performance.","archived":false,"fork":false,"pushed_at":"2022-01-04T16:31:52.000Z","size":6077,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-14T23:26:45.696Z","etag":null,"topics":["data-structures","java"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/kothar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-17T17:00:39.000Z","updated_at":"2025-06-23T16:21:07.000Z","dependencies_parsed_at":"2022-07-27T11:02:18.406Z","dependency_job_id":null,"html_url":"https://github.com/kothar/compactlist","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/kothar/compactlist","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kothar%2Fcompactlist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kothar%2Fcompactlist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kothar%2Fcompactlist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kothar%2Fcompactlist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kothar","download_url":"https://codeload.github.com/kothar/compactlist/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kothar%2Fcompactlist/sbom","scorecard":{"id":568379,"data":{"date":"2025-08-11","repo":{"name":"github.com/kothar/compactlist","commit":"28f7068e84579b497b47d11854246ac06331f23e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/maven.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/maven.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/kothar/compactlist/maven.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/maven.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/kothar/compactlist/maven.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 0/16 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 16 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T15:36:54.179Z","repository_id":27786763,"created_at":"2025-08-20T15:36:54.179Z","updated_at":"2025-08-20T15:36:54.179Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28477943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","java"],"created_at":"2026-01-16T06:45:25.873Z","updated_at":"2026-01-16T06:45:25.937Z","avatar_url":"https://github.com/kothar.png","language":"Java","readme":"# CompactList\n\n[![Build Status](https://travis-ci.org/kothar/compactlist.svg?branch=master)](https://travis-ci.org/kothar/compactlist)\n\nCompactList implements the `List\u003cLong\u003e` interface, but internally it uses a tree of variable word-width segments to improve\nperformance and memory usage compared to an `ArrayList`.\n\nSimilar primitive container implementations can be found elsewhere, notably:\n\n  * [Trove][1]\n  * [Guava Primitive Wrappers][2]\n  \n[1]: https://bitbucket.org/trove4j/trove\n[2]: https://google.github.io/guava/releases/19.0/api/docs/com/google/common/primitives/Ints.html#asList(int...)\n\n## Maven\n\nThis project is published to Maven Central via Sonatype OSSRH\n\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003enet.kothar\u003c/groupId\u003e\n  \u003cartifactId\u003ecompactlist\u003c/artifactId\u003e\n  \u003cversion\u003e0.4.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Performance\n\nPerformance of `CompactList` tends to be worse than `ArrayList` for small lists, but gains an advantage \nfor random inserts as list size increases. This is mainly due to the tree structure which limits the\namount of memory that needs to be copied when elements are inserted or removed, or the allocated backing \narray is grown during an append.\n\nThe implementation currently splits segments at 2^16 elements, which is where performance gains for insertion start to appear.\nIn the charts below, `CompactList` beats `ArrayList` when inserting ~2^17 or more elements.\n\nBenchmarks were run on a 2.2 GHz Intel Core i7 running MacOS 12.0.1 and AdoptOpenJDK 11.0.11\n\n`mvn exec:exec` will run the benchmarks.\n \n### Append\nThis benchmark appends sequential values to the end of the list.\n\n![Total time for sequential append](img/append.png)\n![Average operation time for sequential append](img/append_op.png)\n\n### Insert\nThis benchmark inserts sequential values at random locations as the list grows\n\n![Total time for sequential insert](img/insert.png)\n![Average operation time for sequential insert](img/insert_op.png)\n\n### Remove\nThis benchmark creates a list of sequential values by appending, then removes\nelements at random indices until the list is empty.\n\n![Total time for random removal](img/remove.png)\n![Average operation time for random removal](img/remove_op.png)\n\n### Set\nThis benchmark creates a list of sequential values by appending, then sets\nelements at random indices a number of times equal to the size of the list.\n\n![Total time for random set](img/set.png)\n![Average operation time for random set](img/set_op.png)\n\n### Iteration\n\n## Memory usage\n\nMemory usage depends on how regular the data is, since more regular data can be stored with fewer bits. As a baseline,\nnon-compacted `CompactLists` on a 64-bit JVM use roughly one third of the memory of an `ArrayList\u003cLong\u003e`\n(8 bytes per value vs 4 byte pointer + 24 byte Long object per value). Memory usage after compaction\nis close to the underlying storage size for the smallest word width capable of storing the range of values in each segment.\n\n`CompactList` handles regular data such as repeated or ascending values extremely well.\n\nStorage strategies are implemented for word widths of 64, 32, 16, 8, 4 and 0 (constant value).\n\n![Memory usage after append](img/append_mem.png)\n![Memory usage after insertion](img/insert_mem.png)\n![Memory usage after removal](img/remove_mem.png)\n![Memory usage after set](img/set_mem.png)\n\n## Compaction strategy\n\nLists can be compacted manually by calling `CompactList.compact()`.\n\nWhen compacting, several strategies are attempted to reduce the storage size needed:\n\n**Offset** will attempt to add an offset to each value, shifting the zero-point to the middle of the range of values stored in the current block.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkothar%2Fcompactlist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkothar%2Fcompactlist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkothar%2Fcompactlist/lists"}