Skip to content

Instantly share code, notes, and snippets.

@sachanganesh
Created June 2, 2020 18:00
Show Gist options
  • Select an option

  • Save sachanganesh/1051940603827ccebb16e81c72268a6e to your computer and use it in GitHub Desktop.

Select an option

Save sachanganesh/1051940603827ccebb16e81c72268a6e to your computer and use it in GitHub Desktop.
arena-allocated preorder traversal in rust (tree_node)
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