Skip to main content

Elevators

Trait Elevators 

Source
pub trait Elevators {
    // Required methods
    fn get_dest_floors(&self) -> Vec<usize>;
    fn get_energy_spent(&mut self) -> f64;
    fn update_floors(&mut self);
    fn increment_wait_times(&mut self);
    fn append_elevator(
        &mut self,
        capacity: usize,
        energy_up: f64,
        energy_down: f64,
        energy_coef: f64,
    );
    fn update_capacities(&mut self, capacity: usize);
}
Expand description

§Elevators trait

A Elevators implementation is representative of a collection of Elevators. It is implemented by the Building struct.

Required Methods§

Source

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

Source

fn get_energy_spent(&mut self) -> f64

Source

fn update_floors(&mut self)

Source

fn increment_wait_times(&mut self)

Source

fn append_elevator( &mut self, capacity: usize, energy_up: f64, energy_down: f64, energy_coef: f64, )

Source

fn update_capacities(&mut self, capacity: usize)

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Elevators for Vec<Elevator>

Source§

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

Get an aggregated list of destination floors across the vector of elevators.

Source§

fn get_energy_spent(&mut self) -> f64

Calculate the total energy spent across the vector of elevators.

Source§

fn update_floors(&mut self)

For each elevator, update its floor based on its stopped boolean and its moving_up boolean.

Source§

fn increment_wait_times(&mut self)

For each elevator, increment the wait times of the people on the elevator if they are not on their desired floor.

Source§

fn append_elevator( &mut self, capacity: usize, energy_up: f64, energy_down: f64, energy_coef: f64, )

Appends a new elevator to the collection of elevators

Source§

fn update_capacities(&mut self, capacity: usize)

Updates the capacity across each of the elevators

Implementors§