Created
February 21, 2016 22:51
-
-
Save zchtodd/a74079d90b4f9d8c055f to your computer and use it in GitHub Desktop.
This file contains 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
#![crate_type="lib"] | |
#![crate_name="btree"] | |
const BTREE_ORDER: usize = 5; | |
const MEDIAN_NODE: usize = (BTREE_ORDER - 1) / 2; | |
pub trait TreeNode<T, K, N: TreeNode<T, K, N>> { | |
fn insert(&self, key: T, value: K) -> (T, N); | |
} | |
pub struct InteriorNode<T, K, N: TreeNode<T, K, N>> { | |
pub keys: Vec<T>, | |
pub children: Vec<Box<TreeNode<T, K, N>>>, | |
} | |
pub struct LeafNode<T, K> { | |
pub keys: Vec<T>, | |
pub values: Vec<K>, | |
} | |
impl<T, K, N: TreeNode<T, K, N>> TreeNode<T, K, N> for InteriorNode<T, K, N> { | |
fn insert(&self, key: T, value: K) -> (T, N) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment