{"id":13507337,"url":"https://github.com/tyre/sorted_set","last_synced_at":"2025-12-12T00:17:38.844Z","repository":{"id":32179911,"uuid":"35753334","full_name":"tyre/sorted_set","owner":"tyre","description":"Sorted Set library for Elixir","archived":false,"fork":false,"pushed_at":"2017-05-22T18:42:14.000Z","size":232,"stargazers_count":22,"open_issues_count":1,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T15:56:11.088Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/tyre.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":"2015-05-17T05:29:55.000Z","updated_at":"2025-02-04T11:28:43.000Z","dependencies_parsed_at":"2022-09-01T05:22:42.334Z","dependency_job_id":null,"html_url":"https://github.com/tyre/sorted_set","commit_stats":null,"previous_names":["senecasystems/sorted_set"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tyre/sorted_set","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyre%2Fsorted_set","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyre%2Fsorted_set/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyre%2Fsorted_set/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyre%2Fsorted_set/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tyre","download_url":"https://codeload.github.com/tyre/sorted_set/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyre%2Fsorted_set/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280290184,"owners_count":26305279,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"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":[],"created_at":"2024-08-01T02:00:31.462Z","updated_at":"2025-10-21T15:56:27.428Z","avatar_url":"https://github.com/tyre.png","language":"Elixir","funding_links":[],"categories":["Algorithms and Data structures"],"sub_categories":[],"readme":"# SortedSet\n[![Hex.pm](https://img.shields.io/hexpm/v/sorted_set.svg)](https://hex.pm/packages/sorted_set) [![Travis](https://img.shields.io/travis/SenecaSystems/sorted_set.svg)](https://travis-ci.org/SenecaSystems/sorted_set)\n\n\nA sorted set library for Elixir. Implements the\n[Set](http://elixir-lang.org/docs/v1.0/elixir/Set.html) protocol.\n\n## Installation\n\nAdd the following to `deps` section of your `mix.exs`:\n  `{:sorted_set, \"~\u003e 1.0\"}`\n\nand then `mix deps.get`. That's it!\n\nGenerate the documentation with `mix docs`.\n\n## About\n\nSorted sets are backed by a [red-black tree](http://en.wikipedia.org/wiki/Red%E2%80%93black_tree), providing lookup in O(log(n)). Size is tracked automatically, resulting in O(1)\nperformance.\n\n\n## Basic Usage\n\n`SortedSet` implements the `Set` behaviour, `Enumerable`, and `Collectable`.\n\n```elixir\nSortedSet.new()\n|\u003e Set.put(5)\n|\u003e Set.put(1)\n|\u003e Set.put(3)\n|\u003e Enum.reduce([], fn (element, acc) -\u003e [element*2|acc] end)\n|\u003e Enum.reverse\n# =\u003e [2, 6, 10]\n```\n\n## Custom Comparison\n\nSorted Set can also take a custom `:comparator` function to determine ordering. The\nfunction should accept two terms and\n\n  - return `0` if they are considered equal\n  - return `-1` if the first is considered less than or before the second\n  - return `1` if the first is considered greater than or after the second\n\nThis function is passed on to the underlying [red-black tree implementation](https://github.com/SenecaSystems/red_black_tree) implemetation. Otherwise, the\ndefault Erlang term comparison is used (with an extra bit to handle edgecases — see note in [RedBlackTree](https://github.com/SenecaSystems/red_black_tree)\nREADME.)\n\n```elixir\nSortedSet.new([:a, :b, :c], comparator: fn (term1, term2) -\u003e\n   RedBlackTree.compare_terms(term1, term2) * -1\n end)\n# =\u003e #SortedSet\u003c[:c, :b, :a]\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyre%2Fsorted_set","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyre%2Fsorted_set","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyre%2Fsorted_set/lists"}