/// Inserts a new element into the group. Returns whether the element is new.
Inserts a new element into the group. Returns whether the element is new.
Inserts a new element into the group . Returns whether the element is new .
fn insert(&mut self, el: T) -> bool {
        use std::collections::btree_map::Entry::*;
        match self.elements.entry(Wrapper::from_inner(el.clone())) {
            // If the element is new, we add it to the queue as well.
            Vacant(entry) => {
                entry.insert(1);
                self.queue.push_back(el);
                true
            }
            // Bumps the value by 1, or removes the element if this is the last
            // time we'll find the element.
            Occupied(mut entry) => {
                let value = *entry.get();
                if value != self.gens.len() - 1 {
                    entry.insert(value + 1);
                } else {
                    entry.remove_entry();
                }
                // The element is a repeat, except in the special case of the
                // identity.
                value == 0
            }
        }
    }
fn insert ( & mut self , el : T ) -> bool { use std :: collections :: btree_map :: Entry :: * ; match self . elements . entry ( Wrapper :: from_inner ( el . clone ( ) ) ) { // If the element is new, we add it to the queue as well. Vacant ( entry ) => { entry . insert ( 1 ) ; self . queue . push_back ( el ) ; true } // Bumps the value by 1, or removes the element if this is the last // time we'll find the element. Occupied ( mut entry ) => { let value = * entry . get ( ) ; if value != self . gens . len ( ) - 1 { entry . insert ( value + 1 ) ; } else { entry . remove_entry ( ) ; } // The element is a repeat, except in the special case of the // identity. value == 0 } } }
Inserts a new element into the group.
Inserts a new element into the group .
&mut self
el
T