Sim.Routing.DSR
Class Route

java.lang.Object
  extended by Sim.Routing.DSR.Route

public class Route
extends java.lang.Object

Route provides a convenient interface for dealing with routing chains with copy-on-write semantics. Route has a copy-on-write semantic so that any modification to a Route returns a new Route while leaving the original object unmodified. Therefore, a Route instance is immutable. This is the same technique used by java.lang.String.


Constructor Summary
Route(java.lang.Integer... path)
           
 
Method Summary
 Route addHop(int address)
          Adds a hop to the end of this Route.
 boolean containsAddress(int address)
           
 boolean containsLink(int start, int end)
          Returns true if there is a link from 'start' to 'end' in this Route.
 boolean equals(java.lang.Object o)
           
 int getFirstHop()
           
 int getLastHop()
           
 Route getRouteFrom(int address)
          Returns the Route from the node with the given address onwards to the end, or null if the given node is not in Route.
 int getSecondHop()
          Returns the hop following the first hop.
 int getSize()
          Returns the size of this Route if it were to be serialized as bytes.
 int hashCode()
           
 int numHops()
           
 Route removeFirstHop()
           
 Route removeLastHop()
           
 Route reverse()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Route

public Route(java.lang.Integer... path)
Method Detail

numHops

public int numHops()

containsAddress

public boolean containsAddress(int address)

getRouteFrom

public Route getRouteFrom(int address)
Returns the Route from the node with the given address onwards to the end, or null if the given node is not in Route. The returned Route has "address" as its first hop, and the last hop is the same as the last hop from this Route.


containsLink

public boolean containsLink(int start,
                            int end)
Returns true if there is a link from 'start' to 'end' in this Route.


addHop

public Route addHop(int address)
Adds a hop to the end of this Route.


getFirstHop

public int getFirstHop()

getSecondHop

public int getSecondHop()
Returns the hop following the first hop.


getLastHop

public int getLastHop()

removeFirstHop

public Route removeFirstHop()

removeLastHop

public Route removeLastHop()

reverse

public Route reverse()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSize

public int getSize()
Returns the size of this Route if it were to be serialized as bytes.