From dc4bbffb489ecbf3d4d4d48d679c86c383904808 Mon Sep 17 00:00:00 2001 From: "ray.j.greenwell" Date: Wed, 31 Mar 2010 21:11:08 +0000 Subject: [PATCH] - Change ReplacedBy values... - CollectionUtil.limit doesn't need to know the Collection type. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2766 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/util/CollectionUtil.java | 18 +++++++++--------- src/java/com/samskivert/util/Collections.java | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/java/com/samskivert/util/CollectionUtil.java b/src/java/com/samskivert/util/CollectionUtil.java index 359e3192..95042dad 100644 --- a/src/java/com/samskivert/util/CollectionUtil.java +++ b/src/java/com/samskivert/util/CollectionUtil.java @@ -39,6 +39,7 @@ public class CollectionUtil * Adds all items returned by the enumeration to the supplied collection * and returns the supplied collection. */ + @ReplacedBy("com.google.common.collect.Iterators#addAll(Collection, com.google.common.collect.Iterators#forEnumeration(Enumeration))") public static > C addAll (C col, Enumeration enm) { while (enm.hasMoreElements()) { @@ -51,7 +52,7 @@ public class CollectionUtil * Adds all items returned by the iterator to the supplied collection and * returns the supplied collection. */ - @ReplacedBy("com.google.common.collect.Iterators.addAll()") + @ReplacedBy("com.google.common.collect.Iterators#addAll()") public static > C addAll (C col, Iterator iter) { while (iter.hasNext()) { @@ -65,7 +66,7 @@ public class CollectionUtil * returns the supplied collection. If the supplied array is null, nothing * is added to the collection. */ - @ReplacedBy("java.util.Collections.addAll()") + @ReplacedBy("java.util.Collections#addAll()") public static > C addAll (C col, E[] values) { if (values != null) { @@ -81,7 +82,7 @@ public class CollectionUtil * remain, as determined by iteration order. If the Collection is smaller than limit, * it is unmodified. */ - public static void limit (Collection col, int limit) + public static void limit (Collection col, int limit) { int size = col.size(); if (size > limit) { @@ -89,12 +90,11 @@ public class CollectionUtil ((List) col).subList(limit, size).clear(); } else { - Iterator itr = col.iterator(); - int ii = 0; - for (; ii < limit; ii++) { + Iterator itr = col.iterator(); + for (int ii = 0; ii < limit; ii++) { itr.next(); } - for (; ii < size; ii++) { + while (itr.hasNext()) { itr.next(); itr.remove(); } @@ -156,7 +156,7 @@ public class CollectionUtil * Returns an Array, of the type specified by the runtime-type token type, * containing the elements of the collection. */ - @ReplacedBy("com.google.common.collect.Iterables.toArray()") + @ReplacedBy("com.google.common.collect.Iterables#toArray()") public static T[] toArray (Collection col, Class type) { @SuppressWarnings("unchecked") @@ -174,7 +174,7 @@ public class CollectionUtil * order returned by the collection's iterator). The size of the array will * be equal to the size of the collection. */ - @ReplacedBy("com.google.common.primitives.Ints.toArray()") + @ReplacedBy("com.google.common.primitives.Ints#toArray()") public static int[] toIntArray (Collection col) { Iterator iter = col.iterator(); diff --git a/src/java/com/samskivert/util/Collections.java b/src/java/com/samskivert/util/Collections.java index ed44dbcf..a137fb8b 100644 --- a/src/java/com/samskivert/util/Collections.java +++ b/src/java/com/samskivert/util/Collections.java @@ -38,7 +38,7 @@ public class Collections * * @param metaIterable an iterable of Iterators. */ - @ReplacedBy("com.google.common.collect.Iterators.concat() or com.google.common.collect.Iterables.concat()") + @ReplacedBy("com.google.common.collect.Iterators#concat() or com.google.common.collect.Iterables#concat()") public static Iterator getMetaIterator (Iterable> metaIterable) { return new MetaIterator(metaIterable); @@ -139,7 +139,7 @@ public class Collections /** * Get an iterator that returns the same elements as the supplied iterator but blocks removal. */ - @ReplacedBy("com.google.common.collect.Iterators.unmodifiableIterator") + @ReplacedBy("com.google.common.collect.Iterators#unmodifiableIterator()") public static Iterator getUnmodifiableIterator (final Iterator itr) { return new Iterator() {