{"id":27876687,"url":"https://github.com/mattcox/tree","last_synced_at":"2025-10-25T19:03:07.531Z","repository":{"id":189182010,"uuid":"679778173","full_name":"mattcox/Tree","owner":"mattcox","description":"A hierarchical tree structure for Swift","archived":false,"fork":false,"pushed_at":"2024-12-28T10:53:50.000Z","size":1230,"stargazers_count":14,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-29T17:54:51.986Z","etag":null,"topics":["hierarchy","ios","macos","sequence","structure","swift","tree"],"latest_commit_sha":null,"homepage":"https://mattcox.github.io/Tree/","language":"Swift","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/mattcox.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}},"created_at":"2023-08-17T15:40:53.000Z","updated_at":"2024-12-28T10:53:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"9c6d9d51-7e26-476f-9bc6-af09f557c924","html_url":"https://github.com/mattcox/Tree","commit_stats":null,"previous_names":["mattcox/tree"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattcox%2FTree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattcox%2FTree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattcox%2FTree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattcox%2FTree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattcox","download_url":"https://codeload.github.com/mattcox/Tree/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252429957,"owners_count":21746571,"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":["hierarchy","ios","macos","sequence","structure","swift","tree"],"created_at":"2025-05-05T02:51:31.976Z","updated_at":"2025-10-25T19:03:07.443Z","avatar_url":"https://github.com/mattcox.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tree\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Swift-orange.svg\" alt=\"Swift\" /\u003e\n    \u003ca href=\"https://swift.org/package-manager\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/swiftpm-compatible-brightgreen.svg?style=flat\" alt=\"Swift Package Manager\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\nWelcome to **Tree**, a Swift package implementing a hierarchical tree structure\nconstructed of interconnected nodes.\n\n\u003cp align=\"center\"\u003e\n    \u003cpicture\u003e\n        \u003csource srcset=\"./Resources/tree~dark.png\" media=\"(prefers-color-scheme: dark)\"\u003e\n        \u003cimg src=\"./Resources/tree.png\" width=\"300\" max-width=\"90%\" alt=\"An example of a basic tree hierarchy\"\u003e\n    \u003c/picture\u003e\n\u003c/p\u003e\n\n## Usage\n\nTree's store a value associated with each node. This can be any identifiable\ntype. The identifier is used for tracking the identity of a node within the\ntree.\n\nBuilding a tree is simple; you create a root node and add child nodes.\n\n```swift\n// Create a root node.\n//\nlet root = Node(\"root\")\n\n// Create two nodes as children of the root node.\n//\nlet A = root.append(child: \"A\")\nlet B = root.append(child: \"B\")\n\n// Create some leaf nodes as children of node A.\n//\nlet C = A.append(child: \"C\")\nlet D = A.append(child: \"D\")\n```\n\nBuilding a tree is even easier with the declarative tree builder.\n\n```swift\nlet root = Root(\"root\") {\n    Branch(\"A\") {\n        \"C\"\n        \"D\"\n    }\n    \n    \"B\"\n}\n```\n\nThe tree can then be enumerated of inspected for properties.\n\n```swift\nprint(root.isRoot)\n// \"true\"\n\nprint(root.isLeaf)\n// \"false\"\n\nif let A = root.node(identifiedBy: \"A\") {\n    print(A.reduce(\"\") {\n        $0 + \"\\($1.element), \"\n    })\n    // \"C, D, \"\n}\n```\n\n## Documentation\n\nFor more information on usage, the Tree documentation can be found at: https://mattcox.github.io/Tree/.\n\n## Installation\n\nTree is distributed using the [Swift Package Manager](https://swift.org/package-manager). To install it within another Swift package, add it as a dependency within your `Package.swift` manifest:\n\n```swift\nlet package = Package(\n    // . . .\n    dependencies: [\n        .package(url: \"https://github.com/mattcox/Tree.git\", branch: \"main\")\n    ],\n    // . . .\n)\n```\n\nIf you’d like to use Tree within an iOS, macOS, watchOS or tvOS app, then use Xcode’s `File \u003e Add Packages...` menu command to add it to your project.\n\nImport Tree wherever you’d like to use it:\n```swift\nimport Tree\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattcox%2Ftree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattcox%2Ftree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattcox%2Ftree/lists"}