Struct elevate_lib::floor::Floor

source ·
pub struct Floor {
    pub capacity: usize,
    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§

§capacity: usize§dest_prob: f64

Implementations§

source§

impl Floor

§Floor type implementation

The following functions are used by Buildings and Floors implementations.

source

pub fn new(capacity: usize) -> Floor

Initialize a new Floor with a zero destination probability and an empty vector of Persons.

§Example
let capacity: usize = 100_usize;
let my_floor: Floor = Floor::new(capacity);
source

pub fn get_free_capacity(&self) -> usize

Calculate the free capacity for the floor

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, free_elevator_capacity: usize ) -> 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. The people removed from the floor are limited to the free capacity of the elevator they are entering, which is given as a usize function parameter.

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 copy 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_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 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> 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

§

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,

§

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>,

§

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>,

§

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