Author: simonetripodi
Date: Thu Mar  1 08:06:02 2012
New Revision: 1295459

URL: http://svn.apache.org/viewvc?rev=1295459&view=rev
Log:
moved QueueOrStack type inference in the class definition (it is known that is 
a VertexPair DataStructure, so no need to specify it when instantiating but 
rather in the type itself)

Modified:
    
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/DefaultVisitAlgorithmsSelector.java

Modified: 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/DefaultVisitAlgorithmsSelector.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/DefaultVisitAlgorithmsSelector.java?rev=1295459&r1=1295458&r2=1295459&view=diff
==============================================================================
--- 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/DefaultVisitAlgorithmsSelector.java
 (original)
+++ 
commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/visit/DefaultVisitAlgorithmsSelector.java
 Thu Mar  1 08:06:02 2012
@@ -76,7 +76,7 @@ final class DefaultVisitAlgorithmsSelect
      */
     public <O> O applyingBreadthFirstSearch( GraphVisitHandler<V, E, G, O> 
handler )
     {
-        return applyingSearch( handler, new QueueOrStack<VertexPair<V>>( true 
) );
+        return applyingSearch( handler, new QueueOrStack<V>( true ) );
     }
 
     /**
@@ -84,7 +84,7 @@ final class DefaultVisitAlgorithmsSelect
      */
     public <O> O applyingDepthFirstSearch( GraphVisitHandler<V, E, G, O> 
handler )
     {
-        return applyingSearch( handler, new QueueOrStack<VertexPair<V>>( false 
) );
+        return applyingSearch( handler, new QueueOrStack<V>( false ) );
     }
 
     /**
@@ -101,7 +101,7 @@ final class DefaultVisitAlgorithmsSelect
      * @param vertexList the collection used to traverse the graph
      * @return the result of {@link GraphVisitHandler#onCompleted()}
      */
-    private <O> O applyingSearch( GraphVisitHandler<V, E, G, O> handler, 
QueueOrStack<VertexPair<V>> vertexList )
+    private <O> O applyingSearch( GraphVisitHandler<V, E, G, O> handler, 
QueueOrStack<V> vertexList )
     {
         handler = checkNotNull( handler, "Graph visitor handler can not be 
null." );
 
@@ -173,13 +173,13 @@ final class DefaultVisitAlgorithmsSelect
      *
      * @param <V> the Graph vertices type
      */
-    private static class QueueOrStack<P>
+    private static class QueueOrStack<V extends Vertex>
     {
         /** indicated the collection behavior. */
         private boolean isQueue;
 
         /** the underlying linked list implementation. */
-        private final LinkedList<P> list;
+        private final LinkedList<VertexPair<V>> list;
 
         /**
          * Create a new {@link QueueOrStack} instance with the desired
@@ -191,7 +191,7 @@ final class DefaultVisitAlgorithmsSelect
         public QueueOrStack( final boolean isQueue )
         {
             this.isQueue = isQueue;
-            this.list = new LinkedList<P>();
+            this.list = new LinkedList<VertexPair<V>>();
         }
 
         /**
@@ -199,7 +199,7 @@ final class DefaultVisitAlgorithmsSelect
          *
          * @param element the element to be added
          */
-        public void push( P element )
+        public void push( VertexPair<V> element )
         {
             list.addLast( element );
         }
@@ -209,7 +209,7 @@ final class DefaultVisitAlgorithmsSelect
          * defined behavior (LIFO vs. FIFO).
          * @return the next element
          */
-        public P pop()
+        public VertexPair<V> pop()
         {
             return isQueue ? list.removeFirst() : list.removeLast();
         }


Reply via email to