{"id":16019604,"url":"https://github.com/iboard/tree_map","last_synced_at":"2025-04-05T03:25:09.326Z","repository":{"id":194855845,"uuid":"692022522","full_name":"iboard/tree_map","owner":"iboard","description":"An Elixir module to handle a tree of data","archived":false,"fork":false,"pushed_at":"2023-09-18T06:12:26.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T08:08:51.466Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iboard.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-09-15T11:48:02.000Z","updated_at":"2023-09-15T11:48:31.000Z","dependencies_parsed_at":"2024-10-14T01:15:43.272Z","dependency_job_id":null,"html_url":"https://github.com/iboard/tree_map","commit_stats":null,"previous_names":["iboard/tree_map"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboard%2Ftree_map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboard%2Ftree_map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboard%2Ftree_map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iboard%2Ftree_map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iboard","download_url":"https://codeload.github.com/iboard/tree_map/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247283369,"owners_count":20913562,"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-10-08T17:04:54.235Z","updated_at":"2025-04-05T03:25:09.296Z","avatar_url":"https://github.com/iboard.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# README \n## TreeMap 0.1\n\n\n[![Elixir CI](https://github.com/iboard/tree_map/actions/workflows/elixir.yml/badge.svg)](https://github.com/iboard/tree_map/actions/workflows/elixir.yml)\n[![Package version](http://img.shields.io/hexpm/v/tree_map.svg?style=flat)](https://hex.pm/packages/tree_map)\n[![Package documentation](http://img.shields.io/badge/hex.pm-docs-green.svg?style=flat)](https://hexdocs.pm/tree_map)\n\nA module to maintain a tree of the structure `TreeMap.Node` and to start root-nodes as \nsupervised children of `TreeMap.RootServer`.\n\n### Node Structure\n\n```elixir\n  %Node{ key: ..., value: ..., children: [%Node{},...]}\n```\n\n### Function to traverse `%Node{}`\n\n```elixir\n root =\n   TreeMap.new(\"1\", \"Root\")\n   |\u003e TreeMap.add_child(\"1.1\", \"Sub One\", [TreeMap.new(\"1.1.1\", \"SomeSubSub\")])\n   |\u003e TreeMap.add_child(\"1.2\", \"Sub Two\", [TreeMap.new(\"1.2.1\", \"Some other SubSub\")])\n\n expected = [\"1\", \"1.1\", \"1.1.1\", \"1.2\", \"1.2.1\"]\n\n received =\n   TreeMap.transduce(root, [], fn a, x -\u003e a ++ [x] end, fn n, acc -\u003e [n | acc] end)\n   |\u003e Enum.map(\u0026 \u00261.key)\n\n assert expected == received\n```\n\n### RootServer\n\n`TreeMap.RootServer` is a `DynamicSupervisor` that can be used to maintain a tree of `TreeMap` nodes.\n\n    iex\u003e TreeMap.start_root_node(\"A\", \"Root\")\n    {:ok, pid}\n\n    iex\u003e TreeMap.list_roots()\n    [%Node{}, ...]\n\n    iex\u003e TreeMap.find(\"key\")\n    %Node{}\n\n    iex\u003e TreeMap.drop_all()\n    [:ok, ...]\n\n\n## Installation\n\n[Available in Hex](https://hex.pm/packages/tree_map), the package can be \ninstalled by adding `tree_map` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:tree_map, \"~\u003e 0.1.0\"}\n  ]\nend\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiboard%2Ftree_map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiboard%2Ftree_map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiboard%2Ftree_map/lists"}