Skip to content

Instantly share code, notes, and snippets.

@zchtodd
Created February 21, 2016 22:51
Show Gist options
  • Save zchtodd/a74079d90b4f9d8c055f to your computer and use it in GitHub Desktop.
Save zchtodd/a74079d90b4f9d8c055f to your computer and use it in GitHub Desktop.
#![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