public class Route extends Object implements Serializable
NetworkException
.
Copyright (c) 2013-2014 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights
reserved.
BSD-style license. See OpenTrafficSim License.
Constructor and Description |
---|
Route()
Create an empty route.
|
Route(List<Node<?,?>> nodes)
Create a route based on an initial list of nodes.
|
Modifier and Type | Method and Description |
---|---|
void |
addNode(int i,
Node<?,?> node)
Add a node at a specific location.
|
boolean |
addNode(Node<?,?> node)
Add a node to the end of the node list.
|
boolean |
containsLink(CrossSectionLink<?,?> link)
FIXME: this fails if this route contains a Node more than once.
|
Node<?,?> |
destinationNode() |
Node<?,?> |
getNode(int i)
Return a node at a specific location.
|
int |
indexOf(Node<?,?> node)
Return the index of a Node in this Route, or -1 if this Route does not contain the specified Node.
|
Node<?,?> |
lastVisitedNode() |
Node<?,?> |
nextNodeToVisit()
This method does not advance the route pointer.
|
Node<?,?> |
originNode() |
Node<?,?> |
removeNode(int i)
Remove a node from a specific location.
|
int |
size() |
String |
toString() |
Node<?,?> |
visitNextNode()
This method does advance the route pointer (if possible).
|
public final boolean addNode(Node<?,?> node) throws NetworkException
node
- the node to add.NetworkException
- when node could not be added.public final void addNode(int i, Node<?,?> node) throws NetworkException
i
- the location to put the node (0-based).node
- the node to add.NetworkException
- when i<0 or i>=nodes.size(). Also thrown when another error occurs.public final Node<?,?> removeNode(int i) throws NetworkException
i
- the location to remove the node from (0-based).NetworkException
- when i is equal to the last visited node because the next link on the route cannot be
computed anymore. Also thrown when another error occurs.public final Node<?,?> getNode(int i) throws NetworkException
i
- the location to get the node from (0-based).NetworkException
- when i<0 or i>=nodes.size().public final Node<?,?> originNode() throws NetworkException
NetworkException
- when the list has no nodes.public final int size()
public final Node<?,?> destinationNode() throws NetworkException
NetworkException
- when the list has no nodes.public final Node<?,?> lastVisitedNode() throws NetworkException
NetworkException
- when the index is out of bounds (should never happen).public final Node<?,?> nextNodeToVisit() throws NetworkException
NetworkException
- when the index is out of bounds (should never happen).public final Node<?,?> visitNextNode() throws NetworkException
NetworkException
- when the index is out of bounds (should never happen).public final boolean containsLink(CrossSectionLink<?,?> link)
link
- the link to check in the route.public final int indexOf(Node<?,?> node)
node
- Node<?, ?>; the Node to findCopyright © 2014–2015 Delft University of Technology. All rights reserved.