5 releases
0.0.5 | Mar 14, 2022 |
---|---|
0.0.4 | Nov 16, 2021 |
0.0.3 | Nov 11, 2021 |
0.0.2 | Oct 14, 2021 |
0.0.1 | Sep 26, 2021 |
#1890 in Data structures
235KB
3K
SLoC
Treena
Treena: Trees stored in an arena.
Yet another arena-tree?
Treena is heavily inspired by indextree crate, but has extra goals.
- Provide an arena to contain multiple independent trees.
- Even when users are manipulating single trees, they may want to create temporary tree. Forest supports such use case.
- Forest provided by treena is a true forest: root nodes of trees in an arena have no siblings relationships among each other.
- Use clear and unambiguous names.
- Traditional function names which are often used for tree manipulation
are very unclear for non-native English speakers.
- For example, what does
A.insert_before(B)
mean? "insert A before B" or "insert B before A"? P.insert_before(A, B)
can be interpreted relatively naturally: "P (parent) inserts the node A before the node B". However,P
here is completely redundant since it must be the parent ofA
.
- For example, what does
- Treena provides these functions as
A.adopt(B, AsFoo)
andforest.insert(A, AsFooOf(B))
. They are much clearer than the traditional names.- For example,
A.adopt(B, AdoptAs::LastChild)
can be read as "the node A adopts the node B as the last child of A". - Another example:
forest.insert(A, InsertAs::NextSiblingOf(B))
can be read as "insert the node A as the next sibling of the node B".
- For example,
- Traditional function names which are often used for tree manipulation
are very unclear for non-native English speakers.
- Be safe and easy to debug.
- No unsafe codes (at least for now). This means that the crate won't run into undefined behavior.
- Using
.expect()
everywhere with meaningful message when it won't fail or should panic for some reason.- For example, if treena panics with
[precondition] node must be alive
, you can be aware immediately that the passed node is not alive but it violates precondition of the function. - Another example: if treena panics with
[consistency] foobarbaz
, it is sure that this is a bug of treena (not you).
- For example, if treena panics with
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE.txt or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT.txt or https://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.