pub trait People {
    // Required methods
    fn gen_num_tips(&self, rng: &mut impl Rng) -> usize;
    fn get_dest_floors(&self) -> Vec<usize>;
    fn get_num_people(&self) -> usize;
    fn get_num_people_waiting(&self) -> usize;
    fn get_num_people_going_to_floor(&self, floor_to: usize) -> usize;
    fn get_aggregate_wait_time(&self) -> usize;
    fn are_people_going_to_floor(&self, floor_index: usize) -> bool;
    fn are_people_waiting(&self) -> bool;
    fn increment_wait_times(&mut self);
    fn reset_wait_times(&mut self);
}
Expand description

§People trait

A People implementation is representative of a collection of Persons. It is implemented by the Elevator and Floor structs. It defines a set of functions for managing Persons in aggregate.

Required Methods§

source

fn gen_num_tips(&self, rng: &mut impl Rng) -> usize

Expected to generate the number of tips to collect from the people

source

fn get_dest_floors(&self) -> Vec<usize>

Expected to determine the destination floors for all people and return it as a vector.

source

fn get_num_people(&self) -> usize

Expected to determine the total number of people and return it as a usize.

source

fn get_num_people_waiting(&self) -> usize

Expected to determine the number of people waiting, that is, not at their desired floor.

source

fn get_num_people_going_to_floor(&self, floor_to: usize) -> usize

Expected to determine the number of people going to a particular floor

source

fn get_aggregate_wait_time(&self) -> usize

Expected to read the wait times from people waiting/not at their desired floor and aggregate the total into a usize.

source

fn are_people_going_to_floor(&self, floor_index: usize) -> bool

Expected to determine whether anyone in the collection of people are going to a given floor, returning a bool which is true if so, and false if not.

source

fn are_people_waiting(&self) -> bool

Expected to determine whether anyone in the collection of people is waiting/not at their desired floor, returning a bool which is true if so, and false if not.

source

fn increment_wait_times(&mut self)

Expected to increment the wait times (by 1_usize) among all people waiting/not at their desired floor.

source

fn reset_wait_times(&mut self)

Expected to reset the wait times (to 0_usize) among all people who have a nonzero wait time and are on their desired floor.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl People for Vec<Person>

source§

fn gen_num_tips(&self, rng: &mut impl Rng) -> usize

Generates the number of people among the collection of people who will tip.

source§

fn get_dest_floors(&self) -> Vec<usize>

Determines the destination floors for all people and returns it as a vector.

source§

fn get_num_people(&self) -> usize

Determines the total number of people and returns it as a usize.

source§

fn get_num_people_waiting(&self) -> usize

Determines the number of people waiting, that is, not at their desired floor.

source§

fn get_num_people_going_to_floor(&self, floor_to: usize) -> usize

Determines the number of people going to a particular floor

source§

fn get_aggregate_wait_time(&self) -> usize

Reads the wait times from people waiting/not at their desired floor and aggregates the total into a usize.

source§

fn are_people_going_to_floor(&self, floor_index: usize) -> bool

Determines whether anyone in the collection of people are going to a given floor, and returns a bool which is true if so, and false if not.

source§

fn are_people_waiting(&self) -> bool

Determines whether anyone in the collection of people is waiting/not at their desired floor, and returns a bool which is true if so, and false if not.

source§

fn increment_wait_times(&mut self)

Increments the wait times (by 1_usize) among all people waiting/not at their desired floor.

source§

fn reset_wait_times(&mut self)

Resets the wait times (to 0_usize) among all people who have a nonzero wait time and are on their desired floor.

Implementors§