bcds.phison
Class Path<V,E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by java.util.LinkedList<E>
                  extended by bcds.phison.Path<V,E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.Deque<E>, java.util.List<E>, java.util.Queue<E>

public class Path<V,E>
extends java.util.LinkedList<E>

A Path object is a list of links all belonging to the same SimGraph object.

Author:
Juan Segovia S.
See Also:
Serialized Form

Field Summary
 SimGraph<V,E> g
          The SimGraph to which this path is bound.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Path(SimGraph<V,E> g)
          Construct a new path bound to a given SimGraph.
 
Method Summary
 java.util.List<V> nodes()
          Returns the list of nodes in this path.
 Path<V,E> reverse()
          Given a path a-b-c-d, returns d-c-b-a.
 V source()
          Returns the source node of the this path object.
 Path<V,E> subList(int start, int end)
          Returns a sublist of links of this path.
 V target()
          Returns the target node of the this path object.
 java.lang.String toString()
          Returns a string of the form v1-v2-v3-...-vn, or the empty string if this path is null.
 
Methods inherited from class java.util.LinkedList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, set, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, removeRange
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, isEmpty, iterator, listIterator, removeAll, retainAll
 
Methods inherited from interface java.util.Deque
iterator
 

Field Detail

g

public final SimGraph<V,E> g
The SimGraph to which this path is bound. Changing this attribute after instantiation is highly discouraged (this will break).

Constructor Detail

Path

public Path(SimGraph<V,E> g)
Construct a new path bound to a given SimGraph.

Method Detail

toString

public java.lang.String toString()
Returns a string of the form v1-v2-v3-...-vn, or the empty string if this path is null. node.toString() is implicitly used to form the representation of each node (typically it is the node id),

Overrides:
toString in class java.util.AbstractCollection<E>

source

public V source()
Returns the source node of the this path object.

Throws:
java.lang.IndexOutOfBoundsException - when the path is empty.

target

public V target()
Returns the target node of the this path object.

Throws:
java.lang.IndexOutOfBoundsException - when the path is empty.

reverse

public Path<V,E> reverse()
Given a path a-b-c-d, returns d-c-b-a. No checking is done to verify that a reverse edge exists.


subList

public Path<V,E> subList(int start,
                         int end)
Returns a sublist of links of this path. The sublist is a new object, not a view from the original path.

Specified by:
subList in interface java.util.List<E>
Overrides:
subList in class java.util.AbstractList<E>

nodes

public java.util.List<V> nodes()
Returns the list of nodes in this path.