{"id":46367450,"url":"https://github.com/hextriclosan/algorithm","last_synced_at":"2026-03-05T02:34:17.969Z","repository":{"id":96154431,"uuid":"530709209","full_name":"hextriclosan/algorithm","owner":"hextriclosan","description":"Collection of Algorithms","archived":false,"fork":false,"pushed_at":"2026-02-15T15:59:07.000Z","size":66,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-15T22:52:46.653Z","etag":null,"topics":["algorithm","algorithms","comparator","functor","iterator","java","permutation-algorithms"],"latest_commit_sha":null,"homepage":"","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/hextriclosan.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-08-30T15:05:47.000Z","updated_at":"2026-02-15T15:59:09.000Z","dependencies_parsed_at":"2024-02-04T11:58:48.449Z","dependency_job_id":"b8a45f9d-e4ca-4e90-a77e-6385b06b9247","html_url":"https://github.com/hextriclosan/algorithm","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/hextriclosan/algorithm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hextriclosan%2Falgorithm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hextriclosan%2Falgorithm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hextriclosan%2Falgorithm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hextriclosan%2Falgorithm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hextriclosan","download_url":"https://codeload.github.com/hextriclosan/algorithm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hextriclosan%2Falgorithm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30107256,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T01:39:18.192Z","status":"online","status_checked_at":"2026-03-05T02:00:06.710Z","response_time":93,"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":["algorithm","algorithms","comparator","functor","iterator","java","permutation-algorithms"],"created_at":"2026-03-05T02:34:17.404Z","updated_at":"2026-03-05T02:34:17.956Z","avatar_url":"https://github.com/hextriclosan.png","language":"Java","readme":"\n# Java Algorithms\n\n## Acquiring Algorithms\nYou can download source and binaries from the [release page](https://github.com/hextriclosan/algorithm/releases/latest).\nAlternatively you can pull it from the central Maven repositories:\n\n#### Maven\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.hextriclosan\u003c/groupId\u003e\n    \u003cartifactId\u003ealgorithm\u003c/artifactId\u003e\n    \u003cversion\u003e0.0.4\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n#### Gradle\n```groovy\nimplementation 'io.github.hextriclosan:algorithm:0.0.4'\n```\n\n## Basic usage\n\n### Collections\n\n##### Disjoint Set\nDisjoint Set a.k.a. Union-Find data structure implementation\n```java\nDisjointSet\u003cString\u003e disjointSet = new DisjointSet\u003c\u003e();\ndisjointSet.makeSets(List.of(\"New York\", \"Los Angeles\", \"Chicago\", \"Houston\"));\n\nrecord Edge(String firstCity, String secondCity, int distance) {\n}\n\nList\u003cEdge\u003e edges = List.of(\n        new Edge(\"New York\", \"Los Angeles\", 2445),\n        new Edge(\"New York\", \"Chicago\", 790),\n        new Edge(\"New York\", \"Houston\", 1628),\n        new Edge(\"Los Angeles\", \"Chicago\", 2015),\n        new Edge(\"Los Angeles\", \"Houston\", 1547),\n        new Edge(\"Chicago\", \"Houston\", 1092)\n);\n\nedges.stream()\n    .sorted(Comparator.comparingInt(Edge::distance))\n    .filter(edge -\u003e disjointSet.find(edge.firstCity()) != disjointSet.find(edge.secondCity()))\n    .forEach(edge -\u003e {\n        disjointSet.union(edge.firstCity(), edge.secondCity());\n        System.out.println(edge);\n    });\n// prints out\n// Edge[firstCity=New York, secondCity=Chicago, distance=790]\n// Edge[firstCity=Chicago, secondCity=Houston, distance=1092]\n// Edge[firstCity=Los Angeles, secondCity=Houston, distance=1547]\n```\n\n### Comparators\n\n##### Lexicographical Comparator\nCompares Iterables lexicographically\n```java\nComparator\u003cIterable\u003cCharacter\u003e\u003e comparator = new LexicographicalComparator\u003c\u003e();\ncomparator.compare(List.of('A', 'B', 'C'), List.of('C', 'B', 'A')); // -1\n```\n\n### Functors\n\n##### Is Sorted Predicate\nEvaluates if Iterable is sorted.\n```java\nPredicate\u003cIterable\u003cCharacter\u003e\u003e predicate = new IsSortedPredicate\u003c\u003e();\npredicate.test(List.of('A', 'B', 'C')); // true\n```\n\n##### Is Permutation Predicate\nEvaluates if one list is permutation of another.\n```java\nBiPredicate\u003cList\u003cCharacter\u003e, List\u003cCharacter\u003e\u003e predicate = new IsPermutationPredicate\u003c\u003e();\npredicate.test(List.of('A', 'B', 'C'), List.of('C', 'B', 'A')); // true\n```\n\n### Iterators\n\n##### Next Permutation Iterator\nInspired by `next_permutation`/`prev_permutation` algorithms from C++ standard\nlibrary. The iterator creates permutations of an input collection, using the lexicographical order.\n```java\nIterator\u003cList\u003cCharacter\u003e\u003e iterator = new NextPermutationIterator\u003c\u003e(List.of('A', 'B', 'B'));\niterator.forEachRemaining(System.out::println);\n// prints out\n// [A, B, B]\n// [B, A, B]\n// [B, B, A]\n```\n\n##### Sampling Iterator\nThis iterator creates random samples of a given size from the input `List`. \nThe algorithm preserves original order of elements.\n```java\nIterator\u003cList\u003cCharacter\u003e\u003e iterator = new SamplingIterator\u003c\u003e(List.of('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'), 3);\niterator.forEachRemaining(System.out::println);\n// one of possible outputs\n// [A, D, H]\n// [B, E, G]\n// [C, F]\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhextriclosan%2Falgorithm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhextriclosan%2Falgorithm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhextriclosan%2Falgorithm/lists"}