fn clean(&mut self, flow: &EntityFlow) {
        // first check all cubes are valid
        self.cube_map.retain(|_, cube| {
            cube.ensure(flow);
            cube.is_valid_cube(flow)
        });

        // then remove all cube_ids in router_map which doesn't exist
        let cube_set: HashSet<CubeId> = self.cube_map.keys().cloned().collect();
        let mut router_set = HashSet::new();
        for vec in self.router_map.values_mut() {
            vec.retain(|id| cube_set.contains(id));
            router_set.extend(vec.iter().cloned());
        }

        // finally compare and remove the un-referenced cubes in cube_map
        for id in cube_set.difference(&router_set) {
            self.cube_map.remove(id);
        }
    }
/// cleans up all invalid cubes in both router_map and cube_map; assumes done ensure_router().
cleans up all invalid cubes in both router_map and cube_map; assumes done ensure_router().
cleans up all invalid cubes in both router_map and cube_map ; assumes done ensure_router () .
fn clean(&mut self, flow: &EntityFlow) {
        // first check all cubes are valid
        self.cube_map.retain(|_, cube| {
            cube.ensure(flow);
            cube.is_valid_cube(flow)
        });
        // then remove all cube_ids in router_map which doesn't exist
        let cube_set: HashSet<CubeId> = self.cube_map.keys().cloned().collect();
        let mut router_set = HashSet::new();
        for vec in self.router_map.values_mut() {
            vec.retain(|id| cube_set.contains(id));
            router_set.extend(vec.iter().cloned());
        }
        // finally compare and remove the un-referenced cubes in cube_map
        for id in cube_set.difference(&router_set) {
            self.cube_map.remove(id);
        }
    }
fn clean ( & mut self , flow : & EntityFlow ) { // first check all cubes are valid self . cube_map . retain ( | _ , cube | { cube . ensure ( flow ) ; cube . is_valid_cube ( flow ) } ) ; // then remove all cube_ids in router_map which doesn't exist let cube_set : HashSet < CubeId > = self . cube_map . keys ( ) . cloned ( ) . collect ( ) ; let mut router_set = HashSet :: new ( ) ; for vec in self . router_map . values_mut ( ) { vec . retain ( | id | cube_set . contains ( id ) ) ; router_set . extend ( vec . iter ( ) . cloned ( ) ) ; } // finally compare and remove the un-referenced cubes in cube_map for id in cube_set . difference ( & router_set ) { self . cube_map . remove ( id ) ; } }
cleans up all invalid cubes in both router_map and cube_map; assumes done ensure_router().
cleans up all invalid cubes in both router_map and cube_map ; assumes done ensure_router () .
&mut self
flow
&EntityFlow
&mut self
flow
&EntityFlow