pub struct Train { /* private fields */ }Expand description
This class implements a train.
A train travels down the track passing or stoping at stations along the way.
Implementations§
Source§impl Train
impl Train
Sourcepub fn new(
name: String,
number: String,
speed: u32,
classnumber: u32,
departure: u32,
startsmile: f64,
start: usize,
end: usize,
) -> Self
pub fn new( name: String, number: String, speed: u32, classnumber: u32, departure: u32, startsmile: f64, start: usize, end: usize, ) -> Self
Create and initialize a train object.
§Parameters:
-
- name The name of the train.
-
- number The number (or symbol) of the train.
-
- speed The maximum (scale) speed of the train.
-
- classnumber The class of the train.
-
- departure The train’s departure time.
-
- startsmile The starting Scale Mile
-
- departure The train’s departure time.
-
- start The originating station index.
-
- end The terminating station index.
Sourcepub fn SetDeparture(&mut self, depart: u32)
pub fn SetDeparture(&mut self, depart: u32)
pub fn DepartureCompare(&self, other: &Self) -> Ordering
Sourcepub fn ClassNumber(&self) -> u32
pub fn ClassNumber(&self) -> u32
Return the class number.
Sourcepub fn NumberOfNotes(&self) -> usize
pub fn NumberOfNotes(&self) -> usize
Number of notes.
Sourcepub fn AddNoteToTrain(&mut self, note: usize)
pub fn AddNoteToTrain(&mut self, note: usize)
Sourcepub fn RemoveNoteFromTrain(&mut self, note: usize)
pub fn RemoveNoteFromTrain(&mut self, note: usize)
pub fn NoteIter(&self) -> Iter<'_, usize>
pub fn NoteIter_mut(&mut self) -> IterMut<'_, usize>
Sourcepub fn UpdateStopLayover(&mut self, istop: usize, layover: f64)
pub fn UpdateStopLayover(&mut self, istop: usize, layover: f64)
Sourcepub fn UpdateStopCab(&mut self, istop: usize, cab: Option<&Cab>)
pub fn UpdateStopCab(&mut self, istop: usize, cab: Option<&Cab>)
Sourcepub fn AddNoteToStop(&mut self, istop: usize, note: usize)
pub fn AddNoteToStop(&mut self, istop: usize, note: usize)
Sourcepub fn RemoveNoteFromStop(&mut self, istop: usize, note: usize)
pub fn RemoveNoteFromStop(&mut self, istop: usize, note: usize)
Sourcepub fn SetOriginStorageTrack(&mut self, trackname: String)
pub fn SetOriginStorageTrack(&mut self, trackname: String)
Sourcepub fn SetDestinationStorageTrack(&mut self, trackname: String)
pub fn SetDestinationStorageTrack(&mut self, trackname: String)
Sourcepub fn SetTransitStorageTrack(&mut self, istop: usize, trackname: String)
pub fn SetTransitStorageTrack(&mut self, istop: usize, trackname: String)
Set an intermediate storage track.
§Parameters:
- istop The stop index.
- trackname The intermediate storage track name.
Sourcepub fn NumberOfStops(&self) -> usize
pub fn NumberOfStops(&self) -> usize
Return the number of stops.
Sourcepub fn StopI(&self, i: usize) -> Option<&Stop>
pub fn StopI(&self, i: usize) -> Option<&Stop>
Return the ith stop object. Returns NULL if the index is out of range.
§Parameters:
- i The index of the stop.
pub fn StopIter(&self) -> Iter<'_, Stop>
pub fn StopIter_mut(&mut self) -> IterMut<'_, Stop>
Sourcepub fn StartSMile(&self) -> f64
pub fn StartSMile(&self) -> f64
Return the start Scale Mile.
pub fn ParseTrain(string: &str) -> Result<(Self, usize), TrainParseError>
pub fn Read( inp: &mut BufReader<File>, cabs: &CabNameMap, ) -> Result<Option<Self>>
pub fn Write(&self, f: &mut BufWriter<File>) -> Result<()>
Trait Implementations§
impl StructuralPartialEq for Train
Auto Trait Implementations§
impl Freeze for Train
impl RefUnwindSafe for Train
impl Send for Train
impl Sync for Train
impl Unpin for Train
impl UnwindSafe for Train
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
Mutably borrows from an owned value. Read more