pub struct NearestController {
pub building: Building,
/* private fields */
}Expand description
§NearestController struct
A NearestController implements the ElevatorController trait. It decides each
elevator’s direction based on the nearest destination floor among people on the
elevator, then the nearest floor with people waiting.
Fields§
§building: BuildingImplementations§
Source§impl NearestController
impl NearestController
Sourcepub fn from(building: Building) -> NearestController
pub fn from(building: Building) -> NearestController
Initialize a new NearestController given a Building.
§Example
let my_building: Building = Building::from(
4_usize,
2_usize,
0.5_f64,
5.0_f64,
2.5_f64,
0.5_f64
);
let my_controller: NearestController = NearestController::from(my_building);Sourcepub fn from_building(building: Building) -> NearestController
pub fn from_building(building: Building) -> NearestController
Initialize a new NearestController from just a building
§Example
let my_building: Building = Building::from(
4_usize,
2_usize,
0.5_f64,
5.0_f64,
2.5_f64,
0.5_f64
);
let my_controller: NearestController = NearestController::from(my_building);Trait Implementations§
Source§impl ElevatorController for NearestController
impl ElevatorController for NearestController
Source§fn get_building(&mut self) -> &Building
fn get_building(&mut self) -> &Building
Get the building belonging to the controller
Source§fn get_building_mut(&mut self) -> &mut Building
fn get_building_mut(&mut self) -> &mut Building
Mutably borrow the building belonging to the controller
Source§fn clone_building(&mut self) -> Building
fn clone_building(&mut self) -> Building
Clone the building belonging to the controller. Generally used when swapping controllers.
Source§fn can_be_upgraded(&self) -> bool
fn can_be_upgraded(&self) -> bool
Return a boolean signifying whether the controller can be upgraded or not. Always returns false, since the NearestController cannot be upgraded.
Source§fn upgrade(&mut self, _incrementation: f64)
fn upgrade(&mut self, _incrementation: f64)
Upgrade the controller given an incrementation float. Does nothing for the NearestController since it cannot be upgraded.
Source§fn update_elevators(&mut self)
fn update_elevators(&mut self)
Decide each elevator’s direction based on the nearest destination floor among people on the elevator, then the nearest floor with people waiting.
Auto Trait Implementations§
impl Freeze for NearestController
impl RefUnwindSafe for NearestController
impl Send for NearestController
impl Sync for NearestController
impl Unpin for NearestController
impl UnwindSafe for NearestController
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<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.