pub struct Floor {
pub dest_prob: f64,
/* private fields */
}Expand description
§Floor struct
A Floor is aggregated by buildings. People travel between them using
elevators. The floor struct generally should not be directly instantiated;
instead it should be managed in aggregate via the Building type.
Fields§
§dest_prob: f64Implementations§
Source§impl Floor
§Floor type implementation
The following functions are used by Buildings and Floors implementations.
impl Floor
§Floor type implementation
The following functions are used by Buildings and Floors implementations.
Sourcepub fn new() -> Floor
pub fn new() -> Floor
Initialize a new Floor with a zero destination probability and an empty
vector of Persons.
§Example
let my_floor: Floor = Floor::new();Sourcepub fn get_p_out(&self) -> f64
pub fn get_p_out(&self) -> f64
Calculate the probability that a person on the floor leaves during the next time step, and return the result as an f64.
Sourcepub fn gen_people_leaving(&mut self, rng: &mut impl Rng)
pub fn gen_people_leaving(&mut self, rng: &mut impl Rng)
Randomly generate whether anyone on the floor is leaving using each Person’s
gen_is_leaving function.
Sourcepub fn flush_people_entering_elevator(&mut self) -> Vec<Person>
pub fn flush_people_entering_elevator(&mut self) -> Vec<Person>
Remove people from a floor who are currently waiting/not on their desired floor
and return as a Vec<Person>. This is used when the elevator is on this floor
and there is an exchange of people between the elevator and the floor.
Sourcepub fn flush_people_leaving_floor(&mut self) -> Vec<Person>
pub fn flush_people_leaving_floor(&mut self) -> Vec<Person>
Remove people entirely who are leaving the building. This is used exclusively on the first floor.
Trait Implementations§
Source§impl Extend<Person> for Floor
impl Extend<Person> for Floor
Source§fn extend<T: IntoIterator<Item = Person>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Person>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl People for Floor
impl People for Floor
Source§fn gen_num_tips(&self, rng: &mut impl Rng) -> usize
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>
fn get_dest_floors(&self) -> Vec<usize>
Determines the destination floors for all people on the floor and returns it as a vector.
Source§fn get_num_people(&self) -> usize
fn get_num_people(&self) -> usize
Determines the total number of people on the floor and returns it as a usize.
Source§fn get_num_people_waiting(&self) -> usize
fn get_num_people_waiting(&self) -> usize
Determines the number of people waiting on the floor, that is, not at their desired floor.
Source§fn get_aggregate_wait_time(&self) -> usize
fn get_aggregate_wait_time(&self) -> usize
Reads the wait times from people waiting on the floor/not at their desired floor and aggregates the total into a usize.
Source§fn are_people_going_to_floor(&self, floor_index: usize) -> bool
fn are_people_going_to_floor(&self, floor_index: usize) -> bool
Determines whether anyone on the floor 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
fn are_people_waiting(&self) -> bool
Determines whether anyone on the floor 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)
fn increment_wait_times(&mut self)
Increments the wait times (by 1_usize) among all people waiting on the floor/not
at their desired floor.
Source§fn reset_wait_times(&mut self)
fn reset_wait_times(&mut self)
Resets the wait times (to 0_usize) among all people on the floor who have a nonzero
wait time and are on their desired floor.
Auto Trait Implementations§
impl Freeze for Floor
impl RefUnwindSafe for Floor
impl Send for Floor
impl Sync for Floor
impl Unpin for Floor
impl UnwindSafe for Floor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.