You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2013/01/23 23:57:56 UTC

[6/9] git commit: IteratorUtil: Add generic method to return sorted list out of a collection

IteratorUtil: Add generic method to return sorted list out of a collection

Signed-off-by: Rohit Yadav <bh...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/cbdeeebc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/cbdeeebc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/cbdeeebc

Branch: refs/heads/master
Commit: cbdeeebc6c1864e9ccdae55d0a125929e7be7b30
Parents: 8273af7
Author: Rohit Yadav <bh...@apache.org>
Authored: Wed Jan 23 13:47:56 2013 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Wed Jan 23 14:57:41 2013 -0800

----------------------------------------------------------------------
 utils/src/com/cloud/utils/IteratorUtil.java |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cbdeeebc/utils/src/com/cloud/utils/IteratorUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/IteratorUtil.java b/utils/src/com/cloud/utils/IteratorUtil.java
index d7a85f1..0a7fd72 100644
--- a/utils/src/com/cloud/utils/IteratorUtil.java
+++ b/utils/src/com/cloud/utils/IteratorUtil.java
@@ -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;
+    }
 }