mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
IteratorUtil: Add generic method to return sorted list out of a collection
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
This commit is contained in:
parent
8273af7cbf
commit
cbdeeebc6c
@ -16,8 +16,11 @@
|
||||
// under the License.
|
||||
package com.cloud.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class IteratorUtil {
|
||||
public static <T> Iterable<T> enumerationAsIterable(final Enumeration<T> e) {
|
||||
@ -51,4 +54,11 @@ public class IteratorUtil {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static
|
||||
<T extends Comparable<? super T>> List<T> asSortedList(Collection<T> c) {
|
||||
List<T> list = new ArrayList<T>(c);
|
||||
java.util.Collections.sort(list);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user