pub fn element_types_common(&self) -> (Vec<Vec<ElementType>>, ElementMap<usize>) {
        let rank = self.rank();

        // A nullitope has no proper elements.
        if rank < 1 {
            return (Vec::new(), ElementMap::new());
        }

        // Stores the different types, the counts of each, and the indices of
        // the types associated to each element.
        let mut types = Vec::new();
        let mut type_counts = Vec::new();
        let mut type_of_element = ElementMap::new();

        // Initializes every element with the zeroth type.
        for el_count in self.el_count_iter() {
            type_of_element.push(vec![0; el_count]);
            types.push(Vec::new());
            type_counts.push(1);
        }

        let mut type_count = rank-1;

        let subspaces = self.element_map_affine_hulls();
        let mut distances = Vec::new();

        // To limit the number of passes, we can turn this into a `for` loop.
        loop {
            // We build element types from the bottom up.
            for r in 1..rank {
                // All element types of this rank.
                let mut types_rank: Vec<ElementType> = Vec::new();
                let mut dict = BTreeMap::new();

                for (i, el) in self[r].iter().enumerate() {
                    let mut sub_type_counts = vec![0; type_counts[r - 1]];

                    for &sub in el.subs.iter() {
                        let sub_type = type_of_element[r - 1][sub];
                        sub_type_counts[sub_type] += 1;
                    }

                    let type_data = TypeData {
                        prev_index: type_of_element[r][i],
                        type_counts: sub_type_counts,
                        heuristics: OrderedFloat(subspaces[r-1][i].distance_heuristic(&mut distances)),
                    };

                    match dict.get(&type_data) {
                        // This is an existing element type.
                        Some(&type_idx) => {
                            type_of_element[r][i] = type_idx;
                            types_rank[type_idx].count += 1;
                        }

                        // This is a new element type.
                        None => {
                            dict.insert(type_data, types_rank.len());
                            type_of_element[r][i] = types_rank.len();
                            types_rank.push(ElementType {
                                example: i,
                                count: 1,
                            });
                        }
                    }
                }

                type_counts[r] = types_rank.len();
                types[r] = types_rank;
            }

            // We do basically the same thing, from the top down.
            for r in (1..rank).rev() {
                // All element types of this rank.
                let mut types_rank: Vec<ElementType> = Vec::new();
                let mut dict = BTreeMap::new();

                for (i, el) in self[r].iter().enumerate() {
                    let mut sup_type_counts = vec![0; type_counts[r + 1]];

                    for &sup in el.sups.iter() {
                        let sup_type = type_of_element[r + 1][sup];
                        sup_type_counts[sup_type] += 1;
                    }

                    let type_data = TypeData {
                        prev_index: type_of_element[r][i],
                        type_counts: sup_type_counts,
                        heuristics: OrderedFloat(subspaces[r-1][i].distance_heuristic(&mut distances)),
                    };

                    match dict.get(&type_data) {
                        // This is an existing element type.
                        Some(&type_idx) => {
                            type_of_element[r][i] = type_idx;
                            types_rank[type_idx].count += 1;
                        }

                        // This is a new element type.
                        None => {
                            dict.insert(type_data, types_rank.len());
                            type_of_element[r][i] = types_rank.len();
                            types_rank.push(ElementType {
                                example: i,
                                count: 1,
                            });
                        }
                    }
                }

                type_counts[r] = types_rank.len();
                types[r] = types_rank;
            }

            let new_type_count: usize = type_counts.iter().sum();
            if new_type_count == type_count {
                break;
            }

            type_count = new_type_count;
        }

        (types, type_of_element)
    }
/// element type of an element is <index>
/// - initialize all elements to <0>
/// - repeat:
/// - iterate over ranks:
///     - start an indexed hashmap that'll store metadata
///     - iterate over elements:
///     - get a vector where indexes are the previous rank's type indexes and values are numbers of subelements of that type
///     - get its metadata - <current index, vector^> - could add heuristics like edge lengths to this metadata sometimes
///     - if metadata matches one already in the hashmap, give it that index,
///         - if not, add a new entry in hashmap and increment index
/// - iterate over ranks backwards, use superelements instead of subelements
/// - get number of types in total, if it's the same as previous loop, stop
element type of an element is 
initialize all elements to <0>
repeat:
iterate over ranks:
start an indexed hashmap that'll store metadata
iterate over elements:
get a vector where indexes are the previous rank's type indexes and values are numbers of subelements of that type
get its metadata -  - could add heuristics like edge lengths to this metadata sometimes
if metadata matches one already in the hashmap, give it that index,
if not, add a new entry in hashmap and increment index
iterate over ranks backwards, use superelements instead of subelements
get number of types in total, if it's the same as previous loop, stop
element type of an element is initialize all elements to <0 > repeat : iterate over ranks : start an indexed hashmap that ' ll store metadata iterate over elements : get a vector where indexes are the previous rank ' s type indexes and values are numbers of subelements of that type get its metadata - - could add heuristics like edge lengths to this metadata sometimes if metadata matches one already in the hashmap give it that index if not add a new entry in hashmap and increment index iterate over ranks backwards use superelements instead of subelements get number of types in total if it ' s the same as previous loop stop
pub fn element_types_common(&self) -> (Vec<Vec<ElementType>>, ElementMap<usize>) {
        let rank = self.rank();
        // A nullitope has no proper elements.
        if rank < 1 {
            return (Vec::new(), ElementMap::new());
        }
        // Stores the different types, the counts of each, and the indices of
        // the types associated to each element.
        let mut types = Vec::new();
        let mut type_counts = Vec::new();
        let mut type_of_element = ElementMap::new();
        // Initializes every element with the zeroth type.
        for el_count in self.el_count_iter() {
            type_of_element.push(vec![0; el_count]);
            types.push(Vec::new());
            type_counts.push(1);
        }
        let mut type_count = rank-1;
        let subspaces = self.element_map_affine_hulls();
        let mut distances = Vec::new();
        // To limit the number of passes, we can turn this into a `for` loop.
        loop {
            // We build element types from the bottom up.
            for r in 1..rank {
                // All element types of this rank.
                let mut types_rank: Vec<ElementType> = Vec::new();
                let mut dict = BTreeMap::new();
                for (i, el) in self[r].iter().enumerate() {
                    let mut sub_type_counts = vec![0; type_counts[r - 1]];
                    for &sub in el.subs.iter() {
                        let sub_type = type_of_element[r - 1][sub];
                        sub_type_counts[sub_type] += 1;
                    }
                    let type_data = TypeData {
                        prev_index: type_of_element[r][i],
                        type_counts: sub_type_counts,
                        heuristics: OrderedFloat(subspaces[r-1][i].distance_heuristic(&mut distances)),
                    };
                    match dict.get(&type_data) {
                        // This is an existing element type.
                        Some(&type_idx) => {
                            type_of_element[r][i] = type_idx;
                            types_rank[type_idx].count += 1;
                        }
                        // This is a new element type.
                        None => {
                            dict.insert(type_data, types_rank.len());
                            type_of_element[r][i] = types_rank.len();
                            types_rank.push(ElementType {
                                example: i,
                                count: 1,
                            });
                        }
                    }
                }
                type_counts[r] = types_rank.len();
                types[r] = types_rank;
            }
            // We do basically the same thing, from the top down.
            for r in (1..rank).rev() {
                // All element types of this rank.
                let mut types_rank: Vec<ElementType> = Vec::new();
                let mut dict = BTreeMap::new();
                for (i, el) in self[r].iter().enumerate() {
                    let mut sup_type_counts = vec![0; type_counts[r + 1]];
                    for &sup in el.sups.iter() {
                        let sup_type = type_of_element[r + 1][sup];
                        sup_type_counts[sup_type] += 1;
                    }
                    let type_data = TypeData {
                        prev_index: type_of_element[r][i],
                        type_counts: sup_type_counts,
                        heuristics: OrderedFloat(subspaces[r-1][i].distance_heuristic(&mut distances)),
                    };
                    match dict.get(&type_data) {
                        // This is an existing element type.
                        Some(&type_idx) => {
                            type_of_element[r][i] = type_idx;
                            types_rank[type_idx].count += 1;
                        }
                        // This is a new element type.
                        None => {
                            dict.insert(type_data, types_rank.len());
                            type_of_element[r][i] = types_rank.len();
                            types_rank.push(ElementType {
                                example: i,
                                count: 1,
                            });
                        }
                    }
                }
                type_counts[r] = types_rank.len();
                types[r] = types_rank;
            }
            let new_type_count: usize = type_counts.iter().sum();
            if new_type_count == type_count {
                break;
            }
            type_count = new_type_count;
        }
        (types, type_of_element)
    }
pub fn element_types_common ( & self ) -> ( Vec < Vec < ElementType > > , ElementMap < usize > ) { let rank = self . rank ( ) ; // A nullitope has no proper elements. if rank < 1 { return ( Vec :: new ( ) , ElementMap :: new ( ) ) ; } // Stores the different types, the counts of each, and the indices of // the types associated to each element. let mut types = Vec :: new ( ) ; let mut type_counts = Vec :: new ( ) ; let mut type_of_element = ElementMap :: new ( ) ; // Initializes every element with the zeroth type. for el_count in self . el_count_iter ( ) { type_of_element . push ( vec ! [ 0 el_count ] ) ; types . push ( Vec :: new ( ) ) ; type_counts . push ( 1 ) ; } let mut type_count = rank - 1 ; let subspaces = self . element_map_affine_hulls ( ) ; let mut distances = Vec :: new ( ) ; // To limit the number of passes, we can turn this into a `for` loop. loop { // We build element types from the bottom up. for r in 1 .. rank { // All element types of this rank. let mut types_rank : Vec < ElementType > = Vec :: new ( ) ; let mut dict = BTreeMap :: new ( ) ; for ( i , el ) in self [ r ] . iter ( ) . enumerate ( ) { let mut sub_type_counts = vec ! [ 0 type_counts [ r 1 ] ] ; for & sub in el . subs . iter ( ) { let sub_type = type_of_element [ r - 1 ] [ sub ] ; sub_type_counts [ sub_type ] += 1 ; } let type_data = TypeData { prev_index : type_of_element [ r ] [ i ] , type_counts : sub_type_counts , heuristics : OrderedFloat ( subspaces [ r - 1 ] [ i ] . distance_heuristic ( & mut distances ) ) , } ; match dict . get ( & type_data ) { // This is an existing element type. Some ( & type_idx ) => { type_of_element [ r ] [ i ] = type_idx ; types_rank [ type_idx ] . count += 1 ; } // This is a new element type. None => { dict . insert ( type_data , types_rank . len ( ) ) ; type_of_element [ r ] [ i ] = types_rank . len ( ) ; types_rank . push ( ElementType { example : i , count : 1 , } ) ; } } } type_counts [ r ] = types_rank . len ( ) ; types [ r ] = types_rank ; } // We do basically the same thing, from the top down. for r in ( 1 .. rank ) . rev ( ) { // All element types of this rank. let mut types_rank : Vec < ElementType > = Vec :: new ( ) ; let mut dict = BTreeMap :: new ( ) ; for ( i , el ) in self [ r ] . iter ( ) . enumerate ( ) { let mut sup_type_counts = vec ! [ 0 type_counts [ r 1 ] ] ; for & sup in el . sups . iter ( ) { let sup_type = type_of_element [ r + 1 ] [ sup ] ; sup_type_counts [ sup_type ] += 1 ; } let type_data = TypeData { prev_index : type_of_element [ r ] [ i ] , type_counts : sup_type_counts , heuristics : OrderedFloat ( subspaces [ r - 1 ] [ i ] . distance_heuristic ( & mut distances ) ) , } ; match dict . get ( & type_data ) { // This is an existing element type. Some ( & type_idx ) => { type_of_element [ r ] [ i ] = type_idx ; types_rank [ type_idx ] . count += 1 ; } // This is a new element type. None => { dict . insert ( type_data , types_rank . len ( ) ) ; type_of_element [ r ] [ i ] = types_rank . len ( ) ; types_rank . push ( ElementType { example : i , count : 1 , } ) ; } } } type_counts [ r ] = types_rank . len ( ) ; types [ r ] = types_rank ; } let new_type_count : usize = type_counts . iter ( ) . sum ( ) ; if new_type_count == type_count { break ; } type_count = new_type_count ; } ( types , type_of_element ) }
element type of an element is <index>
 initialize all elements to <0>
 repeat:
 iterate over ranks:
 start an indexed hashmap that'll store metadata
 iterate over elements:
 get a vector where indexes are the previous rank's type indexes and values are numbers of subelements of that type
 get its metadata - <current index, vector^> - could add heuristics like edge lengths to this metadata sometimes
 if metadata matches one already in the hashmap, give it that index,
 if not, add a new entry in hashmap and increment index
 iterate over ranks backwards, use superelements instead of subelements
 get number of types in total, if it's the same as previous loop, stop
element type of an element is <index > initialize all elements to <0 > repeat : iterate over ranks : start an indexed hashmap that ' ll store metadata iterate over elements : get a vector where indexes are the previous rank ' s type indexes and values are numbers of subelements of that type get its metadata - <current index vector^ > - could add heuristics like edge lengths to this metadata sometimes if metadata matches one already in the hashmap give it that index if not add a new entry in hashmap and increment index iterate over ranks backwards use superelements instead of subelements get number of types in total if it ' s the same as previous loop stop
&self