{"id":22901055,"url":"https://github.com/mpdn/skew-forest","last_synced_at":"2025-04-01T05:41:10.443Z","repository":{"id":57667571,"uuid":"248960776","full_name":"mpdn/skew-forest","owner":"mpdn","description":"Skew-binary random access lists in Rust","archived":false,"fork":false,"pushed_at":"2020-03-21T11:29:03.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-07T21:44:05.235Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/mpdn.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":"2020-03-21T11:19:53.000Z","updated_at":"2020-03-21T11:29:05.000Z","dependencies_parsed_at":"2022-09-26T20:31:56.477Z","dependency_job_id":null,"html_url":"https://github.com/mpdn/skew-forest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpdn%2Fskew-forest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpdn%2Fskew-forest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpdn%2Fskew-forest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpdn%2Fskew-forest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpdn","download_url":"https://codeload.github.com/mpdn/skew-forest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246591782,"owners_count":20801984,"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-12-14T01:31:28.193Z","updated_at":"2025-04-01T05:41:10.423Z","avatar_url":"https://github.com/mpdn.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# skew-forest\n\nAn implementation of skew-binary random access lists.\n\nSkew-binary random access lists are a persistent list data structure. They allow logarithmic\ntime random access. Most notably, online lowest common ancestors can be implemented in\nlogarithmic time in the length of the path.\n\nThese lists are *persistent*, i.e. they allow preserving the old version of itself when mutated\nEg. consider a simple list like this:\n\n```\nA - B - C - D    List: ABCD\n```\n\nIf, after B, we clone the list and append `E` and `F`, we will get the resulting structure:\n\n```\nA - B - C - D    First list: ABCD\n      \\\n        E - F    Second list: ABEF\n```\n\nHere we can see how `A` and `B` will be shared among the two lists. Thus the \"lists\" in skew-\nbinary random access lists can really be seen as paths in a tree instead. To emphasize this,\nthis implmentations refers to skew-binary random access lists as paths, or more specifically\nas the `SkewPath` type.\n\nSince we want to be able to share nodes, the paths themselves do not own the nodes. Instead, the\npaths are indexes into a structure that *does* own the nodes. This structure, the `SkewForest`,\nencapsulates the shared graph of the paths.\n\n## Topology\n\nAn additional wrinkle is that the `SkewForest` and `SkewPath` in this implementation does not\nstore any actual values. They *only* store the path topology, i.e. the sequence of node indexes\nthat forms the nodes of a path. When `push` operation is called on a `SkewPath` the index of the\nnode is returned.\n\nTo actually associate a value with a node, a `SkewMap` can be constructed to map these indices\nto values.\n\n## Example\n\nThe example below demonstrates creating two lists as shown above.\n\n```rust\nuse skew_forest::{SkewForest, SkewPath, SkewPathNode, SkewMap};\n\nlet mut forest = SkewForest::default();\nlet mut path_a = SkewPath::\u003c[SkewPathNode; 8]\u003e::default();\n\n// Push A and B onto `path_a`\nlet node_a = forest.push(\u0026mut path_a);\nlet node_b = forest.push(\u0026mut path_a);\n\n// Clone A to B\nlet mut path_b = path_a.clone();\n\n// Push C and D onto `path_a`\nlet node_c = forest.push(\u0026mut path_a);\nlet node_d = forest.push(\u0026mut path_a);\n\n// Push E and F onto `path_b`\nlet node_e = forest.push(\u0026mut path_b);\nlet node_f = forest.push(\u0026mut path_b);\n\n// Check that `path_a` matches ABCD\nassert_eq!(\n    forest.iter(\u0026path_a).collect::\u003cVec\u003c_\u003e\u003e(),\n    vec![node_a, node_b, node_c, node_d],\n);\n\n// Check that `path_b` matches ABCD\nassert_eq!(\n    forest.iter(\u0026path_b).collect::\u003cVec\u003c_\u003e\u003e(),\n    vec![node_a, node_b, node_e, node_f],\n);\n```\n\nLicense: MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpdn%2Fskew-forest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpdn%2Fskew-forest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpdn%2Fskew-forest/lists"}