| 
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--net.walend.digraph.path.AbstractListGEPath
This abstract class implements the GEPath interface using a List of nodes. It implements all the methods in MutableGEPath as protected, for easy subclassing. By default, it uses an ArrayList, but one constructor allows you to supply the Lists.
| Nested Class Summary | |
private  class | 
AbstractListGEPath.EdgeCountToken
 | 
protected  class | 
AbstractListGEPath.ListEdgeNodeIterator
 | 
| Field Summary | |
private static int | 
DEFAULTCAPACITY
 | 
private  GEDigraph | 
digraph
 | 
private  int | 
modCount
 | 
private  java.util.List | 
nodes
 | 
| Fields inherited from interface net.walend.digraph.GEDigraph | 
EMPTY | 
| Constructor Summary | |
protected  | 
AbstractListGEPath(GEDigraph digraph,
                   java.util.List nodeList)
Creates a new path on digraph that has only node in it, using nodeList.  | 
protected  | 
AbstractListGEPath(GEDigraph digraph,
                   java.lang.Object node)
Creates a new path on digraph that has only node in it with DEFAULTCAPACITY of 7.  | 
protected  | 
AbstractListGEPath(GEDigraph digraph,
                   java.lang.Object node,
                   int nodeCapacity)
Creates a new path on digraph that has only node in it, with a capacity nodeCapacity.  | 
protected  | 
AbstractListGEPath(GEDigraph digraph,
                   java.lang.Object node,
                   java.util.List nodeList)
Creates a new path on digraph that has only node in it, using nodeList.  | 
protected  | 
AbstractListGEPath(GEPath path)
Create a new path that is a copy of path.  | 
protected  | 
AbstractListGEPath(GEPath path,
                   java.util.List nodeList)
Create a new path that is a copy of path, using nodeList.  | 
| Method Summary | |
protected  void | 
addToHead(java.lang.Object node)
Adds a node and edge to the beginning of the path.  | 
protected  void | 
addToTail(java.lang.Object node)
Adds an edge and node to the end of the path.  | 
private  void | 
checkIndices(int startNodeIndex,
             int endNodeIndex)
 | 
private  void | 
checkSubpathIndices(int startNodeIndex,
                    int endNodeIndex,
                    java.lang.Object startNode,
                    java.lang.Object endNode)
 | 
protected  void | 
checkValid()
Throw an InvalidPathException if anything is wrong.  | 
protected  void | 
chopList(java.util.List victim,
         int fromIndex,
         int toIndex)
 | 
 boolean | 
containsEdge(java.lang.Object fromNode,
             java.lang.Object toNode)
Returns true if the digraph contains any edge from fromNode to toNode  | 
 boolean | 
containsGEDigraph(GEDigraph digraph)
Returns true if digraph is a subgraph of this GEDigraph.  | 
 boolean | 
containsNode(java.lang.Object node)
 | 
 boolean | 
containsNodes(java.util.Set nodes)
 | 
 int | 
countInboundEdges(java.lang.Object node)
This implementation takes linear time.  | 
 int | 
countOutboundEdges(java.lang.Object node)
This implementation takes linear time.  | 
 int | 
edgeCount()
This method is wildly inefficient.  | 
 EdgeNodeIterator | 
edgeNodeIterator()
Returns an iterator that iterates across pairs of nodes that make edges.  | 
 java.util.Set | 
getFromNodes(java.lang.Object node)
Returns the set of nodes that can reach this node by crossing one edge.  | 
 java.lang.Object | 
getHead()
 | 
 int | 
getIndexOfNode(java.lang.Object node)
 | 
 int | 
getLastIndexOfNode(java.lang.Object node)
 | 
 java.lang.Object | 
getNodeAtIndex(int index)
 | 
 java.util.List | 
getNodeList()
Returns an immutable list of the nodes.  | 
 java.util.Set | 
getNodes()
 | 
 java.lang.Class | 
getPrincipleInterface()
Returns the class's principle interface for state comparisons.  | 
 GEPath | 
getSubpath(int startNodeIndex,
           int endNodeIndex)
Returns a new path, between startNodeIndex and endNodeIndex, inclusive.  | 
 GEPath | 
getSubpathFirst(java.lang.Object startNode,
                java.lang.Object endNode)
Returns a new path, between the first occurence of startNode and the first occurence of endNode, inclusive.  | 
 GEPath | 
getSubpathFirstToLast(java.lang.Object startNode,
                      java.lang.Object endNode)
Returns a new path, between the first occurence of startNode and the last occurence of endNode, inclusive.  | 
 GEPath | 
getSubpathLast(java.lang.Object startNode,
               java.lang.Object endNode)
Returns a new path, between the last occurence of startNode and the last occurence of endNode, inclusive.  | 
 GEPath | 
getSubpathLastToFirst(java.lang.Object startNode,
                      java.lang.Object endNode)
Returns a new path, between the last occurence of startNode and the first occurence of endNode, inclusive.  | 
 GEDigraph | 
getSupergraph()
Returns the supergraph.  | 
 java.lang.Object | 
getTail()
 | 
 java.util.Set | 
getToNodes(java.lang.Object node)
Returns the set of nodes that can be reached from this node by crossing one edge.  | 
protected  void | 
graftToHead(GEPath path)
Adds a path to the beginning of this path.  | 
protected  void | 
graftToTail(GEPath path)
Adds a path to the end of this path.  | 
 GEDigraph | 
intersectWithGEDigraph(GEDigraph digraph)
Returns a new digraph that is the intersection of this with digraph.  | 
 boolean | 
isEdgeFree()
Returns true if this GEDigraph has no edges.  | 
 boolean | 
isEmpty()
 | 
 int | 
nodeCount()
This method is not terribly efficient.  | 
 java.util.Iterator | 
nodeIterator()
Implementations should explicitly state how they interpret nodeIterator()'s remove method.  | 
 int | 
pathEdgeCount()
Returns the number of edges in the path, including repeats.  | 
 EdgeNodeIterator | 
pathEdgeNodeIterator()
Since ListGEPath is immutable, edgeIterator()'s remove() method throws an UnsupportedOperationException.  | 
 int | 
pathNodeCount()
Returns the number of nodes in the path, including repeates.  | 
 java.util.Iterator | 
pathNodeIterator()
Since ListGEPath is immutable, nodeIterator()'s remove() method throws an UnsupportedOperationException.  | 
protected  GEPath | 
pruneHead(int index)
Removes from the head to the edge at index.  | 
 GEPath | 
pruneHeadFromFirst(java.lang.Object node)
Removes from the head to the first occurance of node.  | 
 GEPath | 
pruneHeadFromLast(java.lang.Object node)
Removes from the head to the last occurance of node.  | 
protected  GEPath | 
pruneTail(int index)
Removes from the edge at index to the tail.  | 
 GEPath | 
pruneTailFromFirst(java.lang.Object node)
Removes from the first occurance of node to the tail.  | 
 GEPath | 
pruneTailFromLast(java.lang.Object node)
Removes from the last occurance of node to the tail.  | 
protected  void | 
removeHead()
Removes the head node from the path.  | 
protected  void | 
removeTail()
Removes the tail node from the path.  | 
 boolean | 
sameGEDigraphAs(GEDigraph digraph)
Returns true if digraph is the same as this, and all their contents have the same state.  | 
 boolean | 
sameGEPathAs(GEPath path)
Returns true if path is the same path as this, on the same digraph.  | 
 boolean | 
sameStateAs(HasState victim)
If two HasStates have the same internal state, return true.  | 
protected  GEPath | 
splice(GEPath path,
       int startNodeIndex,
       int endNodeIndex)
Splices in path between the startNodeIndex and endNodeIndex.  | 
protected  GEPath | 
spliceFirst(GEPath path)
Splices in path between the first occurence of path's head and the first occurence of path's tail.  | 
protected  GEPath | 
spliceFirstToLast(GEPath path)
Splices in path between the first occurence of path's head and the last occurence of path's tail.  | 
protected  GEPath | 
spliceLast(GEPath path)
Splices in path between the last occurence of path's head and the last occurence of path's tail.  | 
protected  GEPath | 
spliceLastToFirst(GEPath path)
Splices in path between the last occurence of path's head and the first occurence of path's tail.  | 
 java.lang.String | 
toString()
 | 
 GEDigraph | 
unionGEDigraph(GEDigraph digraph)
Returns a new digraph that is the union of this with digraph.  | 
 boolean | 
valid()
Returns true if this path is still a subgraph of its supergraph  | 
| Methods inherited from class java.lang.Object | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
private static final int DEFAULTCAPACITY
private java.util.List nodes
private transient volatile int modCount
private GEDigraph digraph
| Constructor Detail | 
protected AbstractListGEPath(GEPath path)
InvalidPathException - if the path is not valid.
protected AbstractListGEPath(GEPath path,
                             java.util.List nodeList)
InvalidPathException - if the path is not valid.
protected AbstractListGEPath(GEDigraph digraph,
                             java.lang.Object node)
InvalidPathException - if the path is not valid (because the node isn't in the supergraph).
protected AbstractListGEPath(GEDigraph digraph,
                             java.lang.Object node,
                             int nodeCapacity)
InvalidPathException - if the path is not valid (because the node isn't in the supergraph).
protected AbstractListGEPath(GEDigraph digraph,
                             java.lang.Object node,
                             java.util.List nodeList)
InvalidPathException - if the path is not valid (because the node isn't in the supergraph).
protected AbstractListGEPath(GEDigraph digraph,
                             java.util.List nodeList)
InvalidPathException - if the path is not valid.| Method Detail | 
protected void checkValid()
public int nodeCount()
nodeCount in interface Digraphpublic int edgeCount()
edgeCount in interface Digraphpublic int pathNodeCount()
pathNodeCount in interface Pathpublic int pathEdgeCount()
pathEdgeCount in interface Pathpublic boolean isEmpty()
isEmpty in interface Digraphpublic boolean containsNode(java.lang.Object node)
containsNode in interface Digraph
public boolean containsEdge(java.lang.Object fromNode,
                            java.lang.Object toNode)
                     throws NodeMissingException
containsEdge in interface DigraphNodeMissingException - if either node is missing from the digraph.
public int countInboundEdges(java.lang.Object node)
                      throws NodeMissingException
countInboundEdges in interface DigraphNodeMissingException - if node is not in the digraph.
public int countOutboundEdges(java.lang.Object node)
                       throws NodeMissingException
countOutboundEdges in interface DigraphNodeMissingException - if node is not in the digraph.
public java.util.Set getFromNodes(java.lang.Object node)
                           throws NodeMissingException
If you know this path is acyclic, override this method with one that takes constant time.
getFromNodes in interface DigraphNodeMissingException - if node is not in the digraph.
public java.util.Set getToNodes(java.lang.Object node)
                         throws NodeMissingException
If you know this path is acyclic, override this method with one that takes constant time.
getToNodes in interface DigraphNodeMissingException - if node is not in the digraph.public java.util.Iterator nodeIterator()
Digraph
nodeIterator in interface Digraphpublic java.util.Iterator pathNodeIterator()
pathNodeIterator in interface Pathpublic EdgeNodeIterator pathEdgeNodeIterator()
pathEdgeNodeIterator in interface Pathpublic EdgeNodeIterator edgeNodeIterator()
Digraph
edgeNodeIterator in interface Digraphpublic java.util.Set getNodes()
getNodes in interface Digraphpublic boolean isEdgeFree()
isEdgeFree in interface Digraphpublic boolean containsNodes(java.util.Set nodes)
containsNodes in interface Digraphpublic boolean containsGEDigraph(GEDigraph digraph)
containsGEDigraph in interface GEDigraphpublic boolean sameGEDigraphAs(GEDigraph digraph)
sameGEDigraphAs in interface GEDigraphpublic GEDigraph intersectWithGEDigraph(GEDigraph digraph)
intersectWithGEDigraph in interface GEDigraphpublic GEDigraph unionGEDigraph(GEDigraph digraph)
unionGEDigraph in interface GEDigraphpublic java.lang.Class getPrincipleInterface()
HasState
getPrincipleInterface in interface HasStatepublic boolean sameStateAs(HasState victim)
HasStateFor objects with subobjects, Generally this method should only return true if the internal objects are equal. Implement a contentsHaveSameState() method to determine if the contents have the same state.
sameStateAs in interface HasStatepublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean valid()
valid in interface Pathpublic GEDigraph getSupergraph()
getSupergraph in interface GEPathpublic java.lang.Object getHead()
getHead in interface Pathpublic java.lang.Object getTail()
getTail in interface Pathpublic java.lang.Object getNodeAtIndex(int index)
getNodeAtIndex in interface Pathpublic int getIndexOfNode(java.lang.Object node)
getIndexOfNode in interface Pathpublic int getLastIndexOfNode(java.lang.Object node)
getLastIndexOfNode in interface Pathpublic java.util.List getNodeList()
getNodeList in interface Path
private void checkIndices(int startNodeIndex,
                          int endNodeIndex)
                   throws InvalidSpliceException
InvalidSpliceException
public GEPath getSubpath(int startNodeIndex,
                         int endNodeIndex)
                  throws InvalidSpliceException
getSubpath in interface GEPathInvalidSpliceException
private void checkSubpathIndices(int startNodeIndex,
                                 int endNodeIndex,
                                 java.lang.Object startNode,
                                 java.lang.Object endNode)
                          throws NodeMissingException,
                                 InvalidSpliceException
NodeMissingException
InvalidSpliceException
public GEPath getSubpathFirst(java.lang.Object startNode,
                              java.lang.Object endNode)
                       throws NodeMissingException,
                              InvalidSpliceException
getSubpathFirst in interface GEPathNodeMissingException - if the nodes are not in the path.
InvalidSpliceException - if the nodes are not in the right order.
public GEPath getSubpathLast(java.lang.Object startNode,
                             java.lang.Object endNode)
                      throws NodeMissingException,
                             InvalidSpliceException
getSubpathLast in interface GEPathNodeMissingException - if the nodes are not in the path.
InvalidSpliceException - if the nodes are not in the right order.
public GEPath getSubpathFirstToLast(java.lang.Object startNode,
                                    java.lang.Object endNode)
                             throws NodeMissingException,
                                    InvalidSpliceException
getSubpathFirstToLast in interface GEPathNodeMissingException - if the nodes are not in the path.
InvalidSpliceException - if the nodes are not in the right order.
public GEPath getSubpathLastToFirst(java.lang.Object startNode,
                                    java.lang.Object endNode)
                             throws NodeMissingException,
                                    InvalidSpliceException
getSubpathLastToFirst in interface GEPathNodeMissingException - if the nodes are not in the path.
InvalidSpliceException - if the nodes are not in the right order.public boolean sameGEPathAs(GEPath path)
sameGEPathAs in interface GEPath
protected void addToTail(java.lang.Object node)
                  throws EdgeMissingException,
                         NodeMissingException
returns true if the operation is successful, false if the path is unchanged.
EdgeMissingException - if the edge is not in the digraph between the tail node and node.
NodeMissingException - if the node is not in the digraph.
protected void addToHead(java.lang.Object node)
                  throws EdgeMissingException,
                         NodeMissingException
returns true if the operation is successful, false if the path is unchanged.
EdgeMissingException - if the edge is not in the digraph between the tail node and node.
NodeMissingException - if the node is not in the digraph.
protected void graftToTail(GEPath path)
                    throws EdgeMissingException,
                           NodeMissingException,
                           InvalidSpliceException
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's head node is not this' tail node.
protected void graftToHead(GEPath path)
                    throws EdgeMissingException,
                           NodeMissingException,
                           InvalidSpliceException
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's tail node is not this' head node.
protected void removeHead()
                   throws LastNodeException
LastNodeException
protected void removeTail()
                   throws LastNodeException
LastNodeException
protected void chopList(java.util.List victim,
                        int fromIndex,
                        int toIndex)
protected GEPath pruneTail(int index)
protected GEPath pruneHead(int index)
public GEPath pruneTailFromFirst(java.lang.Object node)
                          throws NodeMissingException
NodeMissingException - if the node is not in the digraph.
public GEPath pruneTailFromLast(java.lang.Object node)
                         throws NodeMissingException
NodeMissingException - if the node is not in the digraph.
public GEPath pruneHeadFromFirst(java.lang.Object node)
                          throws NodeMissingException
NodeMissingException - if the node is not in the digraph.
public GEPath pruneHeadFromLast(java.lang.Object node)
                         throws NodeMissingException
NodeMissingException - if the node is not in the digraph.
protected GEPath splice(GEPath path,
                        int startNodeIndex,
                        int endNodeIndex)
                 throws EdgeMissingException,
                        NodeMissingException,
                        InvalidSpliceException
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's head node is not the node in this at startNodeIndex, or if the path's tail node is not the node in this at endNodeIndex.
protected GEPath spliceFirst(GEPath path)
                      throws EdgeMissingException,
                             NodeMissingException,
                             InvalidSpliceException
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's head node is not the node in this at startNodeIndex, or if the path's tail node is not the node in this at endNodeIndex.
protected GEPath spliceLast(GEPath path)
                     throws EdgeMissingException,
                            NodeMissingException,
                            InvalidSpliceException
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's head node is not the node in this at startNodeIndex, or if the path's tail node is not the node in this at endNodeIndex.
protected GEPath spliceFirstToLast(GEPath path)
                            throws EdgeMissingException,
                                   NodeMissingException,
                                   InvalidSpliceException
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's head node is not the node in this at startNodeIndex, or if the path's tail node is not the node in this at endNodeIndex.
protected GEPath spliceLastToFirst(GEPath path)
                            throws EdgeMissingException,
                                   NodeMissingException,
                                   InvalidSpliceException
EdgeMissingException - if the any edge in path is missing from the digraph.
NodeMissingException - if any node in path not in the digraph.
InvalidSpliceException - if path's head node is not the node in this at startNodeIndex, or if the path's tail node is not the node in this at endNodeIndex.
  | 
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||