fn next(&mut self) -> Option<Self::Item> {
        if self.rng.gen_range(0.0, 1.0) >= self.invalid {
            // Valid transaction
            if self.names.len() < self.num_names {
                let name = self.gen_name();
                self.names.insert(name.clone(), 0);
                Some(IntKeyPayload {
                    name,
                    verb: "set".to_string(),
                    value: self.set_value,
                })
            } else {
                let names_map_clone = self.names.clone();
                let index = self.rng.gen_range(0, self.names.len());
                let name = names_map_clone
                    .keys()
                    .nth(index)
                    .expect("There is an indexing bug in the intkey iterator");

                let value = self
                    .names
                    .get(name)
                    .expect("There is an indexing bug in the intkey iterator")
                    .to_owned();

                if value < self.incs_and_decs_per_set {
                    self.names.insert(name.to_string(), value + 1);
                } else {
                    self.names.remove(name);
                }
                Some(self.gen_inc_or_dec(Some(name.to_string())))
            }
        } else {
            // invalid transaction

            Some(IntKeyPayload {
                name: self.gen_name(),
                verb: "invalid".to_string(),
                value: 0,
            })
        }
    }
/// First use RNG to choose between invalid and valid txn.
/// If valid, determine if there have been enough sets. If so choose between inc or dec.
/// If not generate a random name to set.
First use RNG to choose between invalid and valid txn.
If valid, determine if there have been enough sets. If so choose between inc or dec.
If not generate a random name to set.
First use RNG to choose between invalid and valid txn . If valid determine if there have been enough sets . If so choose between inc or dec . If not generate a random name to set .
fn next(&mut self) -> Option<Self::Item> {
        if self.rng.gen_range(0.0, 1.0) >= self.invalid {
            // Valid transaction
            if self.names.len() < self.num_names {
                let name = self.gen_name();
                self.names.insert(name.clone(), 0);
                Some(IntKeyPayload {
                    name,
                    verb: "set".to_string(),
                    value: self.set_value,
                })
            } else {
                let names_map_clone = self.names.clone();
                let index = self.rng.gen_range(0, self.names.len());
                let name = names_map_clone
                    .keys()
                    .nth(index)
                    .expect("There is an indexing bug in the intkey iterator");
                let value = self
                    .names
                    .get(name)
                    .expect("There is an indexing bug in the intkey iterator")
                    .to_owned();
                if value < self.incs_and_decs_per_set {
                    self.names.insert(name.to_string(), value + 1);
                } else {
                    self.names.remove(name);
                }
                Some(self.gen_inc_or_dec(Some(name.to_string())))
            }
        } else {
            // invalid transaction
            Some(IntKeyPayload {
                name: self.gen_name(),
                verb: "invalid".to_string(),
                value: 0,
            })
        }
    }
fn next ( & mut self ) -> Option < Self :: Item > { if self . rng . gen_range ( 0.0 , 1.0 ) >= self . invalid { // Valid transaction if self . names . len ( ) < self . num_names { let name = self . gen_name ( ) ; self . names . insert ( name . clone ( ) , 0 ) ; Some ( IntKeyPayload { name , verb : " " . to_string ( ) , value : self . set_value , } ) } else { let names_map_clone = self . names . clone ( ) ; let index = self . rng . gen_range ( 0 , self . names . len ( ) ) ; let name = names_map_clone . keys ( ) . nth ( index ) . expect ( " " ) ; let value = self . names . get ( name ) . expect ( " " ) . to_owned ( ) ; if value < self . incs_and_decs_per_set { self . names . insert ( name . to_string ( ) , value + 1 ) ; } else { self . names . remove ( name ) ; } Some ( self . gen_inc_or_dec ( Some ( name . to_string ( ) ) ) ) } } else { // invalid transaction Some ( IntKeyPayload { name : self . gen_name ( ) , verb : " " . to_string ( ) , value : 0 , } ) } }
First use RNG to choose between invalid and valid txn.
First use RNG to choose between invalid and valid txn .
&mut self