{"id":37027404,"url":"https://github.com/nblxa/cons-list","last_synced_at":"2026-01-14T03:15:15.460Z","repository":{"id":48789659,"uuid":"189640647","full_name":"nblxa/cons-list","owner":"nblxa","description":"Cons List: a production-grade immutable collection for use in recursive algorithms","archived":false,"fork":false,"pushed_at":"2021-08-07T07:58:49.000Z","size":210,"stargazers_count":4,"open_issues_count":13,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-19T20:38:44.156Z","etag":null,"topics":["collection","cons","fp","functional","immutable","java"],"latest_commit_sha":null,"homepage":"","language":"Java","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/nblxa.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":"2019-05-31T18:29:49.000Z","updated_at":"2022-10-29T09:13:35.000Z","dependencies_parsed_at":"2022-09-26T22:11:00.661Z","dependency_job_id":null,"html_url":"https://github.com/nblxa/cons-list","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/nblxa/cons-list","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nblxa%2Fcons-list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nblxa%2Fcons-list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nblxa%2Fcons-list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nblxa%2Fcons-list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nblxa","download_url":"https://codeload.github.com/nblxa/cons-list/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nblxa%2Fcons-list/sbom","scorecard":{"id":677104,"data":{"date":"2025-08-11","repo":{"name":"github.com/nblxa/cons-list","commit":"e5f6d323361c87e3d8cf18aeb3bcc97ac2ea1b16"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.1,"checks":[{"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":-1,"reason":"no workflows found","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":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"Code-Review","score":0,"reason":"Found 0/1 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":"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":"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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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:0","Info: FSF or OSI recognized license: The Unlicense: LICENSE: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":8,"reason":"1 out of the last 1 releases have a total of 1 signed artifacts.","details":["Info: signed release artifact: cons-list-2.1.0-javadoc.jar.asc: https://github.com/nblxa/cons-list/releases/tag/v2.1.0","Warn: release artifact v2.1.0 does not have provenance: https://api.github.com/repos/nblxa/cons-list/releases/23133613"],"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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 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"}},{"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"}}]},"last_synced_at":"2025-08-21T21:52:15.788Z","repository_id":48789659,"created_at":"2025-08-21T21:52:15.788Z","updated_at":"2025-08-21T21:52:15.788Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408823,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["collection","cons","fp","functional","immutable","java"],"created_at":"2026-01-14T03:15:14.909Z","updated_at":"2026-01-14T03:15:15.451Z","avatar_url":"https://github.com/nblxa.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.nblxa/cons-list/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.nblxa/cons-list)\n[![Build Status](https://travis-ci.com/nblxa/cons-list.svg?branch=master)](https://travis-ci.com/nblxa/cons-list)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=cons-list\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=cons-list)\n[![Coverage Status](https://coveralls.io/repos/github/nblxa/cons-list/badge.svg?branch=master)](https://coveralls.io/github/nblxa/cons-list?branch=master)\n\n# Production-grade Cons List implementation\n\n`ConsList` is an immutable singly-linked list:\n[ConsList.java](cons-list/src/main/java/io/github/nblxa/cons/ConsList.java).\n\nThis reliable and performant version of singly-linked\nCons List in Java implements the `java.util.Collection` interface, giving\nthe programmers the access to all its methods such as `stream()`,\n`toString()` and others.\n\nThis implementation of Cons List does not use recursion, so it will\nnot cause a `StackOverflowError`. A list is allowed to contain more\nthan `Integer.MAX_VALUE` elements and will produce an overhead of two\nobject references per element.\n\nFor further performance increase, primitive-type specializations can be used:\n`IntConsList`, `LongConsList`, and `DoubleConsList`, all of which extend\nthe parent `ConsList` interface, while adding their own primitive-based methods\non top.\n\nCollection methods are implemented:\n* `size()` iterates through the list to avoid storing list length\n* `isEmpty()` does not try to calculate the size to see if it is 0.\n\nJava 8 Streams support:\n* `spliterator()` has the right characteristics for the cons list:\n  `ORDERED` and `IMMUTABLE`.\n* a custom Collector `toConsCollector()` is provided.\n\nMethods `equals(Object o)` and `hashCode()` are also implemented\nwithout recursion.\n\nFinally, the class is `Serializable`. The serialization and de-serialization\noperations are implemented using loops instead of recursion, thereby\nsafeguarding against a `StackOverflowError`.\n\n---\n\nCons List, due to its simplicity and immutability, is an ideal data\nstructure for multi-threaded processing of ordered collections of data.\nDirect implementations however, suffer from heavy recsive calls\nand may cause high stack memory consumption, if not more severe issues.\nThis implementation fuses the power of the immutable cons list\nwith the wide range of functionality offered by the Java Collections\nand Streams API.\n\n## Maven\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.nblxa\u003c/groupId\u003e\n    \u003cartifactId\u003econs-list\u003c/artifactId\u003e\n    \u003cversion\u003e2.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nThe library uses [Semantic Versioning](https://semver.org).\n\n## Usage\n\nStatic imports for ease of use:\n\n```java\nimport static io.github.nblxa.cons.ConsList.*;\n```\n\nCreate an empty Cons list:\n\n```java\nCollection\u003c?\u003e empty = nil();\n```\n\nCreate a list of an arbitrary length:\n\n```java\nCollection\u003cString\u003e strings = list(\"Hello\", \"functional\", \"programming\", \"!\");\n```\n\nAdding new elements to a list is just creating new immutable lists:\n\n```java\nCollection\u003cString\u003e strings2 = cons(\"ConsList\", cons(\"says:\", strings));\n```\n\nNote that since Cons List is immutable, it must be initialized with elements\nat the time of creation. Another option is to initialize it with elements of\nanother `Iterable`:\n\n```java\nCollection\u003cString\u003e colors = consList(Arrays.asList(\"red\", \"black\", \"magenta\"));\n```\n\nCreate a primitive-based list of `long` values:\n\n```java\nLongConsList\u003cLong\u003e longs = longList(1L, 1L, 2L, 3L, 5L, 8L, 13L);\n```\n\nCreate a list from a `Stream`:\n\n```java\nConsList\u003cString\u003e fruit = Arrays.stream(new String[] {\"Apples\", \"Bananas\", \"Oranges\"})\n    .filter(f -\u003e !f.startsWith(\"O\"))\n    .collect(toConsCollector());\n```\n\n## Performance\n\nBeing an immutable collection, `ConsList` lets one save resources on defensive\ncopying where it would otherwise have been necessary for mutable collections,\nsuch as `ArrayList`.  \n\nSee [ConsListBenchmark.java](cons-list-jmh/src/main/java/io/github/nblxa/ConsListBenchmark.java).\n\nSpecific problems like flattening a tree-like hierarchical structure can be\nsolved more optimally with `ConsList`, however the trivial list-growth and\niteration operations perform better using `java.util.ArrayList`.\n\nSpecialized implementations for primitive types, like the `IntConsList`, \nfor instance, may outperform `ArrayList` in some benchmarks due\nto the lack of boxing. \n\nHere are the benchmark results on the author's machine:\n\n### Benchmark: Flatten a hierarchy\n\nCollection | Avg time, ms/op\n---------- | ----:\n`io.github.nblxa.cons.ConsList` | 29,659\n`java.util.ArrayList` | 78,018\n`java.util.LinkedList` | 112,173\n\n### Benchmark: Grow a list of integers\n\nCollection | Avg time, ms/op\n---------- | ----:\n`io.github.nblxa.cons.IntConsList` | 6,767\n`io.github.nblxa.cons.ConsList` | 22,137\n`java.util.ArrayList` | 9,507\n`java.util.LinkedList` | 14,763\n\n_Note:_ The values for `ConsList` and `IntConsList` assume creating the list with\nthe reversed order of input values compared to those for `ArrayList` and `LinkedList`.\nIf the reversed order is not possible, a somewhat slower `reverse()` or `intReverse()`\noperation is required, adding one single list iteration and re-construction.\n\n### Benchmark: Iterate over a list of integers\n\nCollection | Avg time, ms/op\n---------- | ----:\n`io.github.nblxa.cons.IntConsList` | 3,058\n`io.github.nblxa.cons.ConsList` | 4,845\n`java.util.ArrayList` | 1,989\n`java.util.LinkedList` | 10,451\n\n### Running the benchmarks\n\nThe benchmark is written with [JMH](https://openjdk.java.net/projects/code-tools/jmh/).\nTo test the performance on your machine, build the project:\n```bash\n./mvnw clean package\n```\n\nand the benchmarks run:\n```bash\njava -jar cons-list-jmh/target/benchmarks.jar\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnblxa%2Fcons-list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnblxa%2Fcons-list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnblxa%2Fcons-list/lists"}