pub fn create_index<IndexKey, MapOfIndex>(&mut self, make_index_key_callback: fn(&Value) -> IndexKey)
        -> Index<IndexKey, Key, Value, MapOfIndex>
    where
        IndexKey: Clone + Eq + 'static,
        MapOfIndex: MapTrait<IndexKey, BTreeSet<Key>> + Default + Sized + 'static,
    {
        let mut index_map = MapOfIndex::default();

        self.map.for_each(|key, val| {
            let index_key = make_index_key_callback(&val);
            match index_map.get_mut(&index_key) {
                Some(keys) => {
                    keys.insert(key.clone());
                }
                None => {
                    let mut set = BTreeSet::new();
                    set.insert(key.clone());
                    index_map.insert(index_key, set);
                }
            }
        });

        let index = Index::new(index_map, make_index_key_callback);
        self.indexes.push(Box::new(index.clone()));

        index
    }
/// Create index by value.
/// 'make_index_key_callback' will call everytime when insert or remove on map.
/// Inside into callback necessary to determine the value and type of the index key
/// in any way related to the value of the map.
Create index by value.
'make_index_key_callback' will call everytime when insert or remove on map.
Inside into callback necessary to determine the value and type of the index key
in any way related to the value of the map.
Create index by value . ' make_index_key_callback ' will call everytime when insert or remove on map . Inside into callback necessary to determine the value and type of the index key in any way related to the value of the map .
pub fn create_index<IndexKey, MapOfIndex>(&mut self, make_index_key_callback: fn(&Value) -> IndexKey)
        -> Index<IndexKey, Key, Value, MapOfIndex>
    where
        IndexKey: Clone + Eq + 'static,
        MapOfIndex: MapTrait<IndexKey, BTreeSet<Key>> + Default + Sized + 'static,
    {
        let mut index_map = MapOfIndex::default();
        self.map.for_each(|key, val| {
            let index_key = make_index_key_callback(&val);
            match index_map.get_mut(&index_key) {
                Some(keys) => {
                    keys.insert(key.clone());
                }
                None => {
                    let mut set = BTreeSet::new();
                    set.insert(key.clone());
                    index_map.insert(index_key, set);
                }
            }
        });
        let index = Index::new(index_map, make_index_key_callback);
        self.indexes.push(Box::new(index.clone()));
        index
    }
pub fn create_index < IndexKey , MapOfIndex > ( & mut self , make_index_key_callback : fn ( & Value ) -> IndexKey ) -> Index < IndexKey , Key , Value , MapOfIndex > where IndexKey : Clone + Eq + ' static , MapOfIndex : MapTrait < IndexKey , BTreeSet < Key > > + Default + Sized + ' static , { let mut index_map = MapOfIndex :: default ( ) ; self . map . for_each ( | key , val | { let index_key = make_index_key_callback ( & val ) ; match index_map . get_mut ( & index_key ) { Some ( keys ) => { keys . insert ( key . clone ( ) ) ; } None => { let mut set = BTreeSet :: new ( ) ; set . insert ( key . clone ( ) ) ; index_map . insert ( index_key , set ) ; } } } ) ; let index = Index :: new ( index_map , make_index_key_callback ) ; self . indexes . push ( Box :: new ( index . clone ( ) ) ) ; index }
Create index by value.
Create index by value .
&mut self
make_index_key_callback
fn(&Value) -> IndexKey
&mut self
make_index_key_callback
fn(&Value) -> IndexKey