Struct oldnav_lib::navdata::route::Route
[−]
[src]
pub struct Route { pub name: Option<String>, pub waypoints: LinkedList<Rc<Waypoint>>, }
Defines a route
Examples
let p1 = SphericalCoordinate::from_geographic(0.0, 38.0, 144.0); let c1 = Rc::new(Waypoint::new("1A", "Waypoint 1A", p1, None)); let p2 = SphericalCoordinate::from_geographic(0.0, 39.0, 144.0); let c2 = Rc::new(Waypoint::new("1B", "Waypoint 1B", p2, None)); let p3 = SphericalCoordinate::from_geographic(0.0, 39.0, 145.0); let c3 = Rc::new(Waypoint::new("1C", "Waypoint 1C", p3, None)); let mut route = Route::new(Some(String::from("a new route"))); route.append_waypoint(c1.clone()); route.append_waypoint(c2.clone()); route.append_waypoint(c3.clone()); assert_eq!(route.first().unwrap().name, c1.name); assert_eq!(route.last().unwrap().name, c3.name);
Fields
name: Option<String>
Name of the Route
waypoints: LinkedList<Rc<Waypoint>>
Legs of the Route
Methods
impl Route
[src]
fn new(name: Option<String>) -> Route
Constructor for Route
fn append(&mut self, other: &mut Route)
Move all legs from other
route to the end of this route.
This reuses all the nodes from other
and moves them into
self
. After this operation other
route is emptied.
This operation should be in O(1) time and memory.
fn insert_waypoint(&mut self, index: usize, waypoint: Rc<Waypoint>)
Insert a waypoint into this route at the given index position.
fn append_waypoint(&mut self, waypoint: Rc<Waypoint>)
Append a waypoint to the end of this route.
fn len(&self) -> usize
Returns the number of waypoints in the route.
fn first(&self) -> Option<&Rc<Waypoint>>
Get the first waypoint in the route.
fn last(&self) -> Option<&Rc<Waypoint>>
Get the last waypoint in the route.