rougenoir 0.1.0

A red-black tree and set with callbacks
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::{Set, Tree, TreeCallbacks};

impl<T: Ord, C: TreeCallbacks<Key = T, Value = ()> + Default> FromIterator<T> for Set<T, C> {
    fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Set<T, C> {
        let inputs: Vec<_> = iter.into_iter().collect();

        if inputs.is_empty() {
            return Set::with_callbacks(Default::default());
        }

        let mut tree = Tree::with_callbacks(Default::default());
        for k in inputs {
            tree.insert(k, ());
        }

        Self { tree }
    }
}