1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 20:05:35 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2010-02-07 00:32:59 +00:00
parent a994a84977
commit 7941b24080

View file

@ -14,7 +14,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
/** /**
* Useful utility methods for dealing with Collections. * Useful utility methods for dealing with Collections.
* *
@ -26,7 +25,6 @@ public final class CollectionUtils {
// this class has just static utility methods // this class has just static utility methods
} }
/** /**
* Returns an iterator that iterates backwards over the given list. * Returns an iterator that iterates backwards over the given list.
* The remove() method is not implemented and will throw UnsupportedOperationException. * The remove() method is not implemented and will throw UnsupportedOperationException.
@ -50,12 +48,11 @@ public final class CollectionUtils {
}; };
} }
/** /**
* Allows a foreach loop to iterate backwards over a list * Allows a foreach loop to iterate backwards over a list
* from the end to the start. * from the end to the start.
* *
* eg) * e.g.
* for(Object o : reverseIterable(list)) { ... } * for(Object o : reverseIterable(list)) { ... }
* *
* @throws NullPointerException if list is null * @throws NullPointerException if list is null
@ -64,14 +61,13 @@ public final class CollectionUtils {
return iterable(reverseIterator(list)); return iterable(reverseIterator(list));
} }
/** /**
* Creates an Iterable instance that just returns * Creates an Iterable instance that just returns
* the given Iterator from its iterator() method. * the given Iterator from its iterator() method.
* *
* This is useful for using an iterator in a foreach loop directly. * This is useful for using an iterator in a foreach loop directly.
* *
* eg) * e.g.
* *
* for(Object o : iterable(list.listIterator())) { * for(Object o : iterable(list.listIterator())) {
* // do something * // do something
@ -80,7 +76,7 @@ public final class CollectionUtils {
* @throws NullPointerException if list is null * @throws NullPointerException if list is null
*/ */
public static <T> Iterable<T> iterable(final Iterator<T> iter) { public static <T> Iterable<T> iterable(final Iterator<T> iter) {
if(iter == null) if (iter == null)
throw new NullPointerException("iter parameter is null"); //$NON-NLS-1$ throw new NullPointerException("iter parameter is null"); //$NON-NLS-1$
return new Iterable<T>() { return new Iterable<T>() {
@ -90,8 +86,6 @@ public final class CollectionUtils {
}; };
} }
/** /**
* Finds the first object in the heterogeneous list that is an instance of * Finds the first object in the heterogeneous list that is an instance of
* the given class, removes it from the list, and returns it. * the given class, removes it from the list, and returns it.
@ -103,9 +97,9 @@ public final class CollectionUtils {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> T findFirstAndRemove(List<?> list, Class<T> clazz) { public static <T> T findFirstAndRemove(List<?> list, Class<T> clazz) {
for(Iterator<?> iter = list.iterator(); iter.hasNext();) { for (Iterator<?> iter = list.iterator(); iter.hasNext();) {
Object o = iter.next(); Object o = iter.next();
if(clazz.isInstance(o)) { if (clazz.isInstance(o)) {
iter.remove(); iter.remove();
return (T) o; // safe return (T) o; // safe
} }