Created
June 2, 2020 18:00
-
-
Save sachanganesh/1051940603827ccebb16e81c72268a6e to your computer and use it in GitHub Desktop.
arena-allocated preorder traversal in rust (tree_node)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub type TreeIndex = usize; | |
| pub struct TreeNode { | |
| pub value: usize, | |
| pub left: Option<TreeIndex>, | |
| pub right: Option<TreeIndex> | |
| } | |
| impl TreeNode { | |
| pub fn new( | |
| value: usize, | |
| left: Option<TreeIndex>, | |
| right: Option<TreeIndex> | |
| ) -> Self { | |
| TreeNode { | |
| value, | |
| left, | |
| right | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment