commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marcospera...@apache.org
Subject svn commit: r1360131 - /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java
Date Wed, 11 Jul 2012 12:07:10 GMT
Author: marcosperanza
Date: Wed Jul 11 12:07:10 2012
New Revision: 1360131

URL: http://svn.apache.org/viewvc?rev=1360131&view=rev
Log:
dropped duplicated code

Modified:
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java?rev=1360131&r1=1360130&r2=1360131&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java
(original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/collections/FibonacciHeap.java
Wed Jul 11 12:07:10 2012
@@ -125,6 +125,9 @@ public final class FibonacciHeap<E>
         else
         {
             // 7 concatenate the root list containing x with root list H
+            node.getLeft().setRight( node.getRight() );
+            node.getRight().setLeft( node.getLeft() );
+            
             node.setLeft( minimumNode );
             node.setRight( minimumNode.getRight() );
             minimumNode.setRight( node );
@@ -366,9 +369,6 @@ public final class FibonacciHeap<E>
             tempRight = x.getRight();
 
             // 4  do add x to the root list of H
-            x.getLeft().setRight( x.getRight() );
-            x.getRight().setLeft( x.getLeft() );
-
             moveToRoot( x );
 
             // 5  p[x] <- NIL
@@ -540,9 +540,6 @@ public final class FibonacciHeap<E>
             if ( minimumNode != null )
             {
                 //  First remove node from root list.
-                pointer.getLeft().setRight( pointer.getRight() );
-                pointer.getRight().setLeft( pointer.getLeft() );
-
                 moveToRoot( pointer );
             }
         }
@@ -603,14 +600,11 @@ public final class FibonacciHeap<E>
      */
     private void cut( FibonacciHeapNode<E> x, FibonacciHeapNode<E> y )
     {
-        // remove x from the child list of y, decrementing degree[y]
-        x.getLeft().setRight( x.getRight() );
-        x.getRight().setLeft( x.getLeft() );
-        y.decraeseDegree();
-
         // add x to the root list of H
         moveToRoot( x );
 
+        // remove x from the child list of y, decrementing degree[y]
+        y.decraeseDegree();
         // p[x] <- NIL
         x.setParent( null );
 



Mime
View raw message