[][src]Struct sim::mechanics::queue::Queue

pub struct Queue {
    pub id: Traversable,
    pub cars: VecDeque<CarID>,
    pub laggy_head: Option<CarID>,
    pub geom_len: Distance,
    pub reserved_length: Distance,
}

A Queue of vehicles on a single lane or turn. No over-taking or lane-changing. This is where https://dabreegster.github.io/abstreet/trafficsim/discrete_event.html#exact-positions is implemented.

Fields

id: Traversablecars: VecDeque<CarID>laggy_head: Option<CarID>

This car's back is still partly in this queue.

geom_len: Distancereserved_length: Distance

When a car's turn is accepted, reserve the vehicle length + FOLLOWING_DISTANCE for the target lane. When the car completely leaves (stops being the laggy_head), free up that space. To prevent blocking the box for possibly scary amounts of time, allocate some of this length first. This is unused for turns themselves. This value can exceed geom_len (for the edge case of ONE long car on a short queue).

Implementations

impl Queue[src]

pub fn new(id: Traversable, map: &Map) -> Queue[src]

pub fn get_car_positions(
    &self,
    now: Time,
    cars: &BTreeMap<CarID, Car>,
    queues: &BTreeMap<Traversable, Queue>
) -> Vec<(CarID, Distance)>
[src]

Farthest along (greatest distance) is first.

fn inner_get_car_positions(
    &self,
    now: Time,
    cars: &BTreeMap<CarID, Car>,
    queues: &BTreeMap<Traversable, Queue>,
    recursed_queues: &mut BTreeSet<Traversable>
) -> Vec<(CarID, Distance)>
[src]

pub fn get_idx_to_insert_car(
    &self,
    start_dist: Distance,
    vehicle_len: Distance,
    now: Time,
    cars: &BTreeMap<CarID, Car>,
    queues: &BTreeMap<Traversable, Queue>
) -> Option<usize>
[src]

pub fn try_to_reserve_entry(&mut self, car: &Car, force_entry: bool) -> bool[src]

If true, there's room and the car must actually start the turn (because the space is reserved).

pub fn room_for_car(&self, car: &Car) -> bool[src]

pub fn free_reserved_space(&mut self, car: &Car)[src]

pub fn target_lane_penalty(&self) -> (usize, usize)[src]

Trait Implementations

impl Clone for Queue[src]

impl<'de> Deserialize<'de> for Queue[src]

impl Serialize for Queue[src]

Auto Trait Implementations

impl RefUnwindSafe for Queue

impl Send for Queue

impl Sync for Queue

impl Unpin for Queue

impl UnwindSafe for Queue

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Send + Sync + Any

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,