mirror of https://github.com/apache/activemq.git
Fixing 2 bugs and adding a nice to have toArrayList() method
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@733888 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
050436d72c
commit
47e6d0482b
|
@ -117,7 +117,6 @@ public class LinkedNode<T extends LinkedNode<T>> {
|
|||
rightTail.next = next; // link list->next
|
||||
next.prev = rightTail; // link list<-next
|
||||
next = rightHead; // this->list
|
||||
list.size++;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.kahadb.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Provides a list of LinkedNode objects.
|
||||
*
|
||||
|
@ -60,9 +62,8 @@ public class LinkedNodeList<T extends LinkedNode<T>> {
|
|||
return;
|
||||
}
|
||||
if (head == null) {
|
||||
reparent(list);
|
||||
head = list.head;
|
||||
list.head = null;
|
||||
reparent(list);
|
||||
} else {
|
||||
getTail().linkAfter(list);
|
||||
}
|
||||
|
@ -124,4 +125,17 @@ public class LinkedNodeList<T extends LinkedNode<T>> {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue