/// Attempts to get the next flag.
Attempts to get the next flag.
Attempts to get the next flag .
pub fn try_next(&mut self) -> FlagNext {
        // We get the current flag from the queue.
        if let Some(current) = self.queue.front() {
            let rank = self.polytope.rank();
            // Applies the current flag change to the current flag.
            let flag_change = self.flag_changes[self.flag_idx];
            let new_flag = current.change(self.polytope, flag_change);
            // Increments the flag index.
            self.flag_idx = if self.flag_idx + 1 == self.flag_changes.len() {
                self.queue.pop_front();
                0
            } else {
                self.flag_idx + 1
            };
            let new_orientation = new_flag.orientation;
            match self.found.entry(new_flag) {
                // If the flag is already in the found dictionary:
                Entry::Occupied(mut occupied_entry) => {
                    *occupied_entry.get_mut() += 1;
                    let val = *occupied_entry.get();
                    // If there's a mismatch between the seen and the expected
                    // orientability, then we know the polytope isn't orientable.
                    if self.orientable && new_orientation != occupied_entry.key().orientation {
                        self.orientable = false;
                        return FlagNext::New(FlagEvent::NonOrientable);
                    }
                    // In any case, if we got here, we know this is a repeated
                    // flag.
                    //
                    // If we've found it all of the times we'll ever find it,
                    // there's no use in keeping it in the dictionary (profiling
                    // shows this is marginally faster than letting it be).
                    if val == rank {
                        occupied_entry.remove();
                    }
                    FlagNext::Repeat
                }
                // If this flag is new, we just add it and return it.
                Entry::Vacant(vacant_entry) => {
                    let new_flag = vacant_entry.key().clone();
                    self.queue.push_back(new_flag.clone());
                    // We've found the flag one (1) time.
                    vacant_entry.insert(1);
                    FlagNext::New(FlagEvent::Flag(new_flag))
                }
            }
        }
        // The queue is empty.
        else {
            FlagNext::None
        }
    }
pub fn try_next ( & mut self ) -> FlagNext { // We get the current flag from the queue. if let Some ( current ) = self . queue . front ( ) { let rank = self . polytope . rank ( ) ; // Applies the current flag change to the current flag. let flag_change = self . flag_changes [ self . flag_idx ] ; let new_flag = current . change ( self . polytope , flag_change ) ; // Increments the flag index. self . flag_idx = if self . flag_idx + 1 == self . flag_changes . len ( ) { self . queue . pop_front ( ) ; 0 } else { self . flag_idx + 1 } ; let new_orientation = new_flag . orientation ; match self . found . entry ( new_flag ) { // If the flag is already in the found dictionary: Entry :: Occupied ( mut occupied_entry ) => { * occupied_entry . get_mut ( ) += 1 ; let val = * occupied_entry . get ( ) ; // If there's a mismatch between the seen and the expected // orientability, then we know the polytope isn't orientable. if self . orientable && new_orientation != occupied_entry . key ( ) . orientation { self . orientable = false ; return FlagNext :: New ( FlagEvent :: NonOrientable ) ; } // In any case, if we got here, we know this is a repeated // flag. // // If we've found it all of the times we'll ever find it, // there's no use in keeping it in the dictionary (profiling // shows this is marginally faster than letting it be). if val == rank { occupied_entry . remove ( ) ; } FlagNext :: Repeat } // If this flag is new, we just add it and return it. Entry :: Vacant ( vacant_entry ) => { let new_flag = vacant_entry . key ( ) . clone ( ) ; self . queue . push_back ( new_flag . clone ( ) ) ; // We've found the flag one (1) time. vacant_entry . insert ( 1 ) ; FlagNext :: New ( FlagEvent :: Flag ( new_flag ) ) } } } // The queue is empty. else { FlagNext :: None } }
Attempts to get the next flag.
Attempts to get the next flag .
&mut self