From 0d73e3819346e751ac2cde9bd1da3e6140f86280 Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 16 Aug 2005 17:39:49 +0000 Subject: [PATCH] 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 --- .../samskivert/src/java/com/samskivert/util/Collections.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/Collections.java b/projects/samskivert/src/java/com/samskivert/util/Collections.java index 320c6f30..a9535538 100644 --- a/projects/samskivert/src/java/com/samskivert/util/Collections.java +++ b/projects/samskivert/src/java/com/samskivert/util/Collections.java @@ -63,9 +63,8 @@ public class Collections Comparator comparator) { SortableArrayList list = new SortableArrayList(); - while (itr.hasNext()) { - list.insertSorted(itr.next(), comparator); - } + CollectionUtil.addAll(list, itr); + list.sort(comparator); return getUnmodifiableIterator(list); }