It's surely faster to add all the elements and then sort, which is why
the class is SortableArrayList rather than SortedArrayList (which would just always insert sorted in add()). git-svn-id: https://samskivert.googlecode.com/svn/trunk@1698 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -63,9 +63,8 @@ public class Collections
|
|||||||
Comparator comparator)
|
Comparator comparator)
|
||||||
{
|
{
|
||||||
SortableArrayList list = new SortableArrayList();
|
SortableArrayList list = new SortableArrayList();
|
||||||
while (itr.hasNext()) {
|
CollectionUtil.addAll(list, itr);
|
||||||
list.insertSorted(itr.next(), comparator);
|
list.sort(comparator);
|
||||||
}
|
|
||||||
return getUnmodifiableIterator(list);
|
return getUnmodifiableIterator(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user