Skip to content

Commit

Permalink
update to be consistent with color
Browse files Browse the repository at this point in the history
  • Loading branch information
KGrewal1 committed Dec 5, 2024
1 parent 4369a73 commit 035496a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
- name: cargo rdme tree_arena
run: |
cargo rdme --check --workspace-project=tree_arena
cargo rdme --check --heading-base-level=0 --workspace-project=tree_arena
clippy-stable:
name: cargo clippy
Expand Down
5 changes: 5 additions & 0 deletions tree_arena/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
[![Linebender Zulip chat.](https://img.shields.io/badge/Linebender-%23masonry-blue?logo=Zulip)](https://xi.zulipchat.com/#narrow/stream/317477-masonry)
[![GitHub Actions CI status.](https://img.shields.io/github/actions/workflow/status/linebender/xilem/ci.yml?logo=github&label=CI)](https://github.com/linebender/xilem/actions)

<!-- We use cargo-rdme to update the README with the contents of lib.rs.
To edit the following section, update it in lib.rs, then run:
cargo rdme --workspace-project=color --heading-base-level=0
Full documentation at https://github.com/orium/cargo-rdme -->

<!-- cargo-rdme start -->

This crate contains two implementations of a tree for use in [Masonry], one safe and the other unsafe. The safe tree is known to work, and serves as the baseline implementation and is used by default.
Expand Down
14 changes: 7 additions & 7 deletions tree_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
//!
//! * Otherwise, [Masonry] uses the safe version.
//!
//! # Architecture
//! ## Architecture
//!
//! ## Safe Tree
//! ### Safe Tree
//!
//! The safe tree contains a root `TreeArena` which owns the root nodes as `Vec<TreeNode<T>>`, and a`parents_map` tracking the parent of every node.
//! Each `TreeNode` subsequently owns its own children as `Vec<TreeNode<T>>`. This model of owneship is thus checked by the rust compiler,
//! but has the downside of requiring passing through every ancestor node to access the descendant -
//! this requires an O(depth) determination of whether the node is a descendant, followed by O(children) time at each level to traverse the path to the child.
//!
//! ## Unsafe Tree
//! ### Unsafe Tree
//!
//! The unsafe tree arena contains a `DataMap` which **owns** all nodes. The `DataMap` contains:
//!
Expand All @@ -38,24 +38,24 @@
//! The aim of this is to reduce the time needed to access node, as given a node, we only need to determine whether it is a descendant of the node being accessed mutably,
//! and do not need to iterate over the children and to flatten the overall tree graph into a hash map.
//!
//! ### Shared References
//! #### Shared References
//!
//! `ArenaRef<'arena, T>` contains the identity of the parent node, a reference to the node data, and `ArenaRefChildren<'arena, T>`.
//! The `ArenaRefChildren<'arena, T>` contains the ids of the children of the node, the id of the node, and a reference to the arena. From this `ArenaRefChildren<'arena, T>` it is possible to get shared access to children of the node.
//!
//! ### Exclusive References
//! #### Exclusive References
//!
//! `ArenaMut<'arena, T>` contains the identity of the parent node, a mutable reference to the node data, and `ArenaMutChildren<'arena, T>`.
//! The `ArenaMutChildren<'arena, T>` contains the ids of the children of the node, the id of the node, and a mutable reference to the arena.
//! From this `ArenaMutChildren<'arena, T>` it is possible to get exclusive access to children of the node.
//!
//! ### Safety
//! #### Safety
//!
//! From the `ArenaMutChildren<'arena, T>`, it is important that we can only access descendants of that node,
//! such that we can only ever have exclusive mutable access to the contents of a node, and never have multiple mutable references.
//! This invariant is not checked by the compiler and thus relies on the logic to determine whether a node is a descendant being correct.
//!
//! ## Complexity
//! ### Complexity
//!
//! |Operation | Safe | Unsafe |
//! | --- | --- | --- |
Expand Down

0 comments on commit 035496a

Please sign in to comment.