IDEA-79726 (Grails: 'Create action' intention should create action in bottom of contr...
authorSergey Evdokimov <sergey.evdokimov@jetbrains.com>
Fri, 27 Jan 2012 16:07:46 +0000 (20:07 +0400)
committerSergey Evdokimov <sergey.evdokimov@jetbrains.com>
Fri, 27 Jan 2012 16:13:59 +0000 (20:13 +0400)
platform/util/src/com/intellij/util/containers/ContainerUtil.java

index 0fe8eaa0f31431079e16788e5787ee941987e84a..a95a6bc627b5ab45276a46bb9416e84441a2b62d 100644 (file)
@@ -677,6 +677,17 @@ public class ContainerUtil {
     return items == null || items.isEmpty() ? def : items.iterator().next();
   }
 
+  @Nullable
+  public static <T> T getLastItem(final Collection<T> items) {
+    Iterator<T> itr = items.iterator();
+    T res = null;
+    while (itr.hasNext()) {
+      res = itr.next();
+    }
+
+    return res;
+  }
+
   @NotNull
   public static <T> Collection<T> subtract(@NotNull Collection<T> from, @NotNull Collection<T> what) {
     final HashSet<T> set = new HashSet<T>(from);