activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r733888 - in /activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util: LinkedNode.java LinkedNodeList.java
Date Mon, 12 Jan 2009 20:17:56 GMT
Author: chirino
Date: Mon Jan 12 12:17:48 2009
New Revision: 733888

URL: http://svn.apache.org/viewvc?rev=733888&view=rev
Log:
Fixing 2 bugs and adding a nice to have toArrayList() method

Modified:
    activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LinkedNode.java
    activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LinkedNodeList.java

Modified: activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LinkedNode.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LinkedNode.java?rev=733888&r1=733887&r2=733888&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LinkedNode.java (original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LinkedNode.java Mon Jan 12
12:17:48 2009
@@ -117,7 +117,6 @@
         rightTail.next = next; // link list->next
         next.prev = rightTail; // link list<-next
         next = rightHead; // this->list
-        list.size++;
     }
 
     /**

Modified: activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LinkedNodeList.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LinkedNodeList.java?rev=733888&r1=733887&r2=733888&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LinkedNodeList.java (original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/util/LinkedNodeList.java Mon Jan
12 12:17:48 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.kahadb.util;
 
+import java.util.ArrayList;
+
 /**
  * Provides a list of LinkedNode objects. 
  * 
@@ -60,9 +62,8 @@
             return;
         }
         if (head == null) {
-            reparent(list);
             head = list.head;
-            list.head = null;
+            reparent(list);
         } else {
             getTail().linkAfter(list);
         }
@@ -124,4 +125,17 @@
         return sb.toString();
     }
     
+    /**
+     * Copies the nodes of the LinkedNodeList to an ArrayList.
+     * @return
+     */
+    public ArrayList<T> toArrayList() {
+    	ArrayList<T> rc = new ArrayList<T>(size);
+    	T cur = head;
+    	while( cur!=null ) {
+    		rc.add(cur);
+    		cur = cur.getNext();
+    	}
+    	return rc;
+    }
 }



Mime
View raw message