Floor

Struct Floor 

Source
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: f64

Implementations§

Source§

impl Floor

§Floor type implementation

The following functions are used by Buildings and Floors implementations.

Source

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();
Source

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.

Source

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.

Source

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.

Source

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 Clone for Floor

Source§

fn clone(&self) -> Floor

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Extend<Person> for Floor

Source§

fn extend<T: IntoIterator<Item = Person>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl People for Floor

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 on the floor and returns it as a vector.

Source§

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

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

Source§

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

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

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)

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)

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V