fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
        // convert into edges and sort
        let mut new_edges: Vec<Edge<M>> = iter.into_iter().map(|e| e.into()).collect();
        // check for early exit
        if new_edges.is_empty() {
            return;
        }

        new_edges.sort_unstable_by_key(|e| (e.from, e.to));

        // replace the old edges with the old ones + new ones merged together
        let old_edges = self.edges.drain(..);
        self.edges = Itertools::merge_by(old_edges, new_edges.into_iter(), |a, b| {
            (a.from, a.to).lt(&(b.from, b.to))
        })
        .collect();
        // finally, re-construct edge_ranges from the new edges
        self.update_edge_ranges();
    }
// note: this is used for CompressedGraph::new as well as FromIterator
this is used for CompressedGraph::new as well as FromIterator
this is used for CompressedGraph :: new as well as FromIterator
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
        // convert into edges and sort
        let mut new_edges: Vec<Edge<M>> = iter.into_iter().map(|e| e.into()).collect();
        // check for early exit
        if new_edges.is_empty() {
            return;
        }
        new_edges.sort_unstable_by_key(|e| (e.from, e.to));
        // replace the old edges with the old ones + new ones merged together
        let old_edges = self.edges.drain(..);
        self.edges = Itertools::merge_by(old_edges, new_edges.into_iter(), |a, b| {
            (a.from, a.to).lt(&(b.from, b.to))
        })
        .collect();
        // finally, re-construct edge_ranges from the new edges
        self.update_edge_ranges();
    }
fn extend < I : IntoIterator < Item = T > > ( & mut self , iter : I ) { // convert into edges and sort let mut new_edges : Vec < Edge < M > > = iter . into_iter ( ) . map ( | e | e . into ( ) ) . collect ( ) ; // check for early exit if new_edges . is_empty ( ) { return ; } new_edges . sort_unstable_by_key ( | e | ( e . from , e . to ) ) ; // replace the old edges with the old ones + new ones merged together let old_edges = self . edges . drain ( .. ) ; self . edges = Itertools :: merge_by ( old_edges , new_edges . into_iter ( ) , | a , b | { ( a . from , a . to ) . lt ( & ( b . from , b . to ) ) } ) . collect ( ) ; // finally, re-construct edge_ranges from the new edges self . update_edge_ranges ( ) ; }
note: this is used for CompressedGraph::new as well as FromIterator
note : this is used for CompressedGraph :: new as well as FromIterator
&mut self
iter
I
&mut self
iter
I