--- jsr166/src/main/java/util/Collections.java 2007/09/11 15:18:34 1.32 +++ jsr166/src/main/java/util/Collections.java 2010/10/16 16:44:39 1.43 @@ -1,5 +1,5 @@ /* - * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -18,9 +18,9 @@ * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. */ package java.util; @@ -61,11 +61,10 @@ import java.lang.reflect.Array; * * @author Josh Bloch * @author Neal Gafter - * @version %I%, %G% - * @see Collection - * @see Set - * @see List - * @see Map + * @see Collection + * @see Set + * @see List + * @see Map * @since 1.2 */ @@ -101,23 +100,42 @@ public class Collections { /** * Sorts the specified list into ascending order, according to the - * natural ordering of its elements. All elements in the list must - * implement the Comparable interface. Furthermore, all elements - * in the list must be mutually comparable (that is, - * e1.compareTo(e2) must not throw a ClassCastException - * for any elements e1 and e2 in the list).

- * - * This sort is guaranteed to be stable: equal elements will - * not be reordered as a result of the sort.

- * - * The specified list must be modifiable, but need not be resizable.

- * - * The sorting algorithm is a modified mergesort (in which the merge is - * omitted if the highest element in the low sublist is less than the - * lowest element in the high sublist). This algorithm offers guaranteed - * n log(n) performance. + * {@linkplain Comparable natural ordering} of its elements. + * All elements in the list must implement the {@link Comparable} + * interface. Furthermore, all elements in the list must be + * mutually comparable (that is, {@code e1.compareTo(e2)} + * must not throw a {@code ClassCastException} for any elements + * {@code e1} and {@code e2} in the list). + * + *

This sort is guaranteed to be stable: equal elements will + * not be reordered as a result of the sort. + * + *

The specified list must be modifiable, but need not be resizable. + * + *

Implementation note: This implementation is a stable, adaptive, + * iterative mergesort that requires far fewer than n lg(n) comparisons + * when the input array is partially sorted, while offering the + * performance of a traditional mergesort when the input array is + * randomly ordered. If the input array is nearly sorted, the + * implementation requires approximately n comparisons. Temporary + * storage requirements vary from a small constant for nearly sorted + * input arrays to n/2 object references for randomly ordered input + * arrays. + * + *

The implementation takes equal advantage of ascending and + * descending order in its input array, and can take advantage of + * ascending and descending order in different parts of the same + * input array. It is well-suited to merging two or more sorted arrays: + * simply concatenate the arrays and sort the resulting array. + * + *

The implementation was adapted from Tim Peters's list sort for Python + * ( + * TimSort). It uses techiques from Peter McIlroy's "Optimistic + * Sorting and Information Theoretic Complexity", in Proceedings of the + * Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 467-474, + * January 1993. * - * This implementation dumps the specified list into an array, sorts + *

This implementation dumps the specified list into an array, sorts * the array, and iterates over the list resetting each element * from the corresponding position in the array. This avoids the * n2 log(n) performance that would result from attempting @@ -125,38 +143,59 @@ public class Collections { * * @param list the list to be sorted. * @throws ClassCastException if the list contains elements that are not - * mutually comparable (for example, strings and integers). + * mutually comparable (for example, strings and integers). * @throws UnsupportedOperationException if the specified list's - * list-iterator does not support the set operation. - * @see Comparable + * list-iterator does not support the {@code set} operation. + * @throws IllegalArgumentException (optional) if the implementation + * detects that the natural ordering of the list elements is + * found to violate the {@link Comparable} contract */ public static > void sort(List list) { - Object[] a = list.toArray(); - Arrays.sort(a); - ListIterator i = list.listIterator(); - for (int j=0; j i = list.listIterator(); + for (int j=0; jmutually * comparable using the specified comparator (that is, - * c.compare(e1, e2) must not throw a ClassCastException - * for any elements e1 and e2 in the list).

+ * {@code c.compare(e1, e2)} must not throw a {@code ClassCastException} + * for any elements {@code e1} and {@code e2} in the list). + * + *

This sort is guaranteed to be stable: equal elements will + * not be reordered as a result of the sort. * - * This sort is guaranteed to be stable: equal elements will - * not be reordered as a result of the sort.

+ *

The specified list must be modifiable, but need not be resizable. * - * The sorting algorithm is a modified mergesort (in which the merge is - * omitted if the highest element in the low sublist is less than the - * lowest element in the high sublist). This algorithm offers guaranteed - * n log(n) performance. + *

Implementation note: This implementation is a stable, adaptive, + * iterative mergesort that requires far fewer than n lg(n) comparisons + * when the input array is partially sorted, while offering the + * performance of a traditional mergesort when the input array is + * randomly ordered. If the input array is nearly sorted, the + * implementation requires approximately n comparisons. Temporary + * storage requirements vary from a small constant for nearly sorted + * input arrays to n/2 object references for randomly ordered input + * arrays. + * + *

The implementation takes equal advantage of ascending and + * descending order in its input array, and can take advantage of + * ascending and descending order in different parts of the same + * input array. It is well-suited to merging two or more sorted arrays: + * simply concatenate the arrays and sort the resulting array. + * + *

The implementation was adapted from Tim Peters's list sort for Python + * ( + * TimSort). It uses techiques from Peter McIlroy's "Optimistic + * Sorting and Information Theoretic Complexity", in Proceedings of the + * Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, pp 467-474, + * January 1993. * - * The specified list must be modifiable, but need not be resizable. - * This implementation dumps the specified list into an array, sorts + *

This implementation dumps the specified list into an array, sorts * the array, and iterates over the list resetting each element * from the corresponding position in the array. This avoids the * n2 log(n) performance that would result from attempting @@ -164,22 +203,23 @@ public class Collections { * * @param list the list to be sorted. * @param c the comparator to determine the order of the list. A - * null value indicates that the elements' natural + * {@code null} value indicates that the elements' natural * ordering should be used. * @throws ClassCastException if the list contains elements that are not - * mutually comparable using the specified comparator. + * mutually comparable using the specified comparator. * @throws UnsupportedOperationException if the specified list's - * list-iterator does not support the set operation. - * @see Comparator + * list-iterator does not support the {@code set} operation. + * @throws IllegalArgumentException (optional) if the comparator is + * found to violate the {@link Comparator} contract */ public static void sort(List list, Comparator c) { - Object[] a = list.toArray(); - Arrays.sort(a, (Comparator)c); - ListIterator i = list.listIterator(); - for (int j=0; j(-(insertion point) - 1). The - * insertion point is defined as the point at which the - * key would be inserted into the list: the index of the first - * element greater than the key, or list.size() if all - * elements in the list are less than the specified key. Note - * that this guarantees that the return value will be >= 0 if - * and only if the key is found. + * otherwise, (-(insertion point) - 1). The + * insertion point is defined as the point at which the + * key would be inserted into the list: the index of the first + * element greater than the key, or list.size() if all + * elements in the list are less than the specified key. Note + * that this guarantees that the return value will be >= 0 if + * and only if the key is found. * @throws ClassCastException if the list contains elements that are not - * mutually comparable (for example, strings and - * integers), or the search key is not mutually comparable - * with the elements of the list. + * mutually comparable (for example, strings and + * integers), or the search key is not mutually comparable + * with the elements of the list. */ public static int binarySearch(List> list, T key) { @@ -224,29 +264,29 @@ public class Collections { private static int indexedBinarySearch(List> list, T key) { - int low = 0; - int high = list.size()-1; + int low = 0; + int high = list.size()-1; + + while (low <= high) { + int mid = (low + high) >>> 1; + Comparable midVal = list.get(mid); + int cmp = midVal.compareTo(key); - while (low <= high) { - int mid = (low + high) >>> 1; - Comparable midVal = list.get(mid); - int cmp = midVal.compareTo(key); - - if (cmp < 0) - low = mid + 1; - else if (cmp > 0) - high = mid - 1; - else - return mid; // key found - } - return -(low + 1); // key not found + if (cmp < 0) + low = mid + 1; + else if (cmp > 0) + high = mid - 1; + else + return mid; // key found + } + return -(low + 1); // key not found } private static int iteratorBinarySearch(List> list, T key) { - int low = 0; - int high = list.size()-1; + int low = 0; + int high = list.size()-1; ListIterator> i = list.listIterator(); while (low <= high) { @@ -269,7 +309,7 @@ public class Collections { * list listIterator. */ private static T get(ListIterator i, int index) { - T obj = null; + T obj = null; int pos = i.nextIndex(); if (pos <= index) { do { @@ -303,19 +343,19 @@ public class Collections { * @param key the key to be searched for. * @param c the comparator by which the list is ordered. * A null value indicates that the elements' - * {@linkplain Comparable natural ordering} should be used. + * {@linkplain Comparable natural ordering} should be used. * @return the index of the search key, if it is contained in the list; - * otherwise, (-(insertion point) - 1). The - * insertion point is defined as the point at which the - * key would be inserted into the list: the index of the first - * element greater than the key, or list.size() if all - * elements in the list are less than the specified key. Note - * that this guarantees that the return value will be >= 0 if - * and only if the key is found. + * otherwise, (-(insertion point) - 1). The + * insertion point is defined as the point at which the + * key would be inserted into the list: the index of the first + * element greater than the key, or list.size() if all + * elements in the list are less than the specified key. Note + * that this guarantees that the return value will be >= 0 if + * and only if the key is found. * @throws ClassCastException if the list contains elements that are not - * mutually comparable using the specified comparator, - * or the search key is not mutually comparable with the - * elements of the list using this comparator. + * mutually comparable using the specified comparator, + * or the search key is not mutually comparable with the + * elements of the list using this comparator. */ public static int binarySearch(List list, T key, Comparator c) { if (c==null) @@ -328,27 +368,27 @@ public class Collections { } private static int indexedBinarySearch(List l, T key, Comparator c) { - int low = 0; - int high = l.size()-1; + int low = 0; + int high = l.size()-1; - while (low <= high) { - int mid = (low + high) >>> 1; - T midVal = l.get(mid); - int cmp = c.compare(midVal, key); - - if (cmp < 0) - low = mid + 1; - else if (cmp > 0) - high = mid - 1; - else - return mid; // key found - } - return -(low + 1); // key not found + while (low <= high) { + int mid = (low + high) >>> 1; + T midVal = l.get(mid); + int cmp = c.compare(midVal, key); + + if (cmp < 0) + low = mid + 1; + else if (cmp > 0) + high = mid - 1; + else + return mid; // key found + } + return -(low + 1); // key not found } private static int iteratorBinarySearch(List l, T key, Comparator c) { - int low = 0; - int high = l.size()-1; + int low = 0; + int high = l.size()-1; ListIterator i = l.listIterator(); while (low <= high) { @@ -387,7 +427,7 @@ public class Collections { ListIterator fwd = list.listIterator(); ListIterator rev = list.listIterator(size); for (int i=0, mid=list.size()>>1; i list, int i, int j) { - final List l = list; - l.set(i, l.set(j, l.get(i))); + final List l = list; + l.set(i, l.set(j, l.get(i))); } /** @@ -510,7 +550,7 @@ public class Collections { * @param list the list to be filled with the specified element. * @param obj The element with which to fill the specified list. * @throws UnsupportedOperationException if the specified list or its - * list-iterator does not support the set operation. + * list-iterator does not support the set operation. */ public static void fill(List list, T obj) { int size = list.size(); @@ -554,7 +594,7 @@ public class Collections { dest.set(i, src.get(i)); } else { ListIterator di=dest.listIterator(); - ListIterator si=src.listIterator(); + ListIterator si=src.listIterator(); for (int i=0; inatural ordering of its elements. * @throws ClassCastException if the collection contains elements that are - * not mutually comparable (for example, strings and - * integers). + * not mutually comparable (for example, strings and + * integers). * @throws NoSuchElementException if the collection is empty. * @see Comparable */ public static > T min(Collection coll) { - Iterator i = coll.iterator(); - T candidate = i.next(); + Iterator i = coll.iterator(); + T candidate = i.next(); while (i.hasNext()) { - T next = i.next(); - if (next.compareTo(candidate) < 0) - candidate = next; - } - return candidate; + T next = i.next(); + if (next.compareTo(candidate) < 0) + candidate = next; + } + return candidate; } /** @@ -613,7 +653,7 @@ public class Collections { * @return the minimum element of the given collection, according * to the specified comparator. * @throws ClassCastException if the collection contains elements that are - * not mutually comparable using the specified comparator. + * not mutually comparable using the specified comparator. * @throws NoSuchElementException if the collection is empty. * @see Comparable */ @@ -621,15 +661,15 @@ public class Collections { if (comp==null) return (T)min((Collection) (Collection) coll); - Iterator i = coll.iterator(); - T candidate = i.next(); + Iterator i = coll.iterator(); + T candidate = i.next(); while (i.hasNext()) { - T next = i.next(); - if (comp.compare(next, candidate) < 0) - candidate = next; - } - return candidate; + T next = i.next(); + if (comp.compare(next, candidate) < 0) + candidate = next; + } + return candidate; } /** @@ -648,21 +688,21 @@ public class Collections { * @return the maximum element of the given collection, according * to the natural ordering of its elements. * @throws ClassCastException if the collection contains elements that are - * not mutually comparable (for example, strings and + * not mutually comparable (for example, strings and * integers). * @throws NoSuchElementException if the collection is empty. * @see Comparable */ public static > T max(Collection coll) { - Iterator i = coll.iterator(); - T candidate = i.next(); + Iterator i = coll.iterator(); + T candidate = i.next(); while (i.hasNext()) { - T next = i.next(); - if (next.compareTo(candidate) > 0) - candidate = next; - } - return candidate; + T next = i.next(); + if (next.compareTo(candidate) > 0) + candidate = next; + } + return candidate; } /** @@ -683,7 +723,7 @@ public class Collections { * @return the maximum element of the given collection, according * to the specified comparator. * @throws ClassCastException if the collection contains elements that are - * not mutually comparable using the specified comparator. + * not mutually comparable using the specified comparator. * @throws NoSuchElementException if the collection is empty. * @see Comparable */ @@ -691,15 +731,15 @@ public class Collections { if (comp==null) return (T)max((Collection) (Collection) coll); - Iterator i = coll.iterator(); - T candidate = i.next(); + Iterator i = coll.iterator(); + T candidate = i.next(); while (i.hasNext()) { - T next = i.next(); - if (comp.compare(next, candidate) > 0) - candidate = next; - } - return candidate; + T next = i.next(); + if (comp.compare(next, candidate) > 0) + candidate = next; + } + return candidate; } /** @@ -783,7 +823,7 @@ public class Collections { i -= size; displaced = list.set(i, displaced); nMoved ++; - } while(i != cycleStart); + } while (i != cycleStart); } } @@ -991,67 +1031,67 @@ public class Collections { * is serializable. * * @param c the collection for which an unmodifiable view is to be - * returned. + * returned. * @return an unmodifiable view of the specified collection. */ public static Collection unmodifiableCollection(Collection c) { - return new UnmodifiableCollection(c); + return new UnmodifiableCollection(c); } /** * @serial include */ static class UnmodifiableCollection implements Collection, Serializable { - private static final long serialVersionUID = 1820017752578914078L; + private static final long serialVersionUID = 1820017752578914078L; - final Collection c; + final Collection c; - UnmodifiableCollection(Collection c) { + UnmodifiableCollection(Collection c) { if (c==null) throw new NullPointerException(); this.c = c; } - public int size() {return c.size();} - public boolean isEmpty() {return c.isEmpty();} - public boolean contains(Object o) {return c.contains(o);} - public Object[] toArray() {return c.toArray();} - public T[] toArray(T[] a) {return c.toArray(a);} + public int size() {return c.size();} + public boolean isEmpty() {return c.isEmpty();} + public boolean contains(Object o) {return c.contains(o);} + public Object[] toArray() {return c.toArray();} + public T[] toArray(T[] a) {return c.toArray(a);} public String toString() {return c.toString();} - public Iterator iterator() { - return new Iterator() { - private final Iterator i = c.iterator(); - - public boolean hasNext() {return i.hasNext();} - public E next() {return i.next();} - public void remove() { - throw new UnsupportedOperationException(); + public Iterator iterator() { + return new Iterator() { + private final Iterator i = c.iterator(); + + public boolean hasNext() {return i.hasNext();} + public E next() {return i.next();} + public void remove() { + throw new UnsupportedOperationException(); } - }; + }; } - public boolean add(E e) { - throw new UnsupportedOperationException(); + public boolean add(E e) { + throw new UnsupportedOperationException(); } - public boolean remove(Object o) { - throw new UnsupportedOperationException(); + public boolean remove(Object o) { + throw new UnsupportedOperationException(); } - public boolean containsAll(Collection coll) { - return c.containsAll(coll); + public boolean containsAll(Collection coll) { + return c.containsAll(coll); } - public boolean addAll(Collection coll) { - throw new UnsupportedOperationException(); + public boolean addAll(Collection coll) { + throw new UnsupportedOperationException(); } - public boolean removeAll(Collection coll) { - throw new UnsupportedOperationException(); + public boolean removeAll(Collection coll) { + throw new UnsupportedOperationException(); } - public boolean retainAll(Collection coll) { - throw new UnsupportedOperationException(); + public boolean retainAll(Collection coll) { + throw new UnsupportedOperationException(); } - public void clear() { - throw new UnsupportedOperationException(); + public void clear() { + throw new UnsupportedOperationException(); } } @@ -1069,19 +1109,19 @@ public class Collections { * @return an unmodifiable view of the specified set. */ public static Set unmodifiableSet(Set s) { - return new UnmodifiableSet(s); + return new UnmodifiableSet(s); } /** * @serial include */ static class UnmodifiableSet extends UnmodifiableCollection - implements Set, Serializable { - private static final long serialVersionUID = -9215047833775013803L; + implements Set, Serializable { + private static final long serialVersionUID = -9215047833775013803L; - UnmodifiableSet(Set s) {super(s);} - public boolean equals(Object o) {return o == this || c.equals(o);} - public int hashCode() {return c.hashCode();} + UnmodifiableSet(Set s) {super(s);} + public boolean equals(Object o) {return o == this || c.equals(o);} + public int hashCode() {return c.hashCode();} } /** @@ -1101,19 +1141,19 @@ public class Collections { * @return an unmodifiable view of the specified sorted set. */ public static SortedSet unmodifiableSortedSet(SortedSet s) { - return new UnmodifiableSortedSet(s); + return new UnmodifiableSortedSet(s); } /** * @serial include */ static class UnmodifiableSortedSet - extends UnmodifiableSet - implements SortedSet, Serializable { - private static final long serialVersionUID = -4929149591599911165L; + extends UnmodifiableSet + implements SortedSet, Serializable { + private static final long serialVersionUID = -4929149591599911165L; private final SortedSet ss; - UnmodifiableSortedSet(SortedSet s) {super(s); ss = s;} + UnmodifiableSortedSet(SortedSet s) {super(s); ss = s;} public Comparator comparator() {return ss.comparator();} @@ -1127,8 +1167,8 @@ public class Collections { return new UnmodifiableSortedSet(ss.tailSet(fromElement)); } - public E first() {return ss.first();} - public E last() {return ss.last();} + public E first() {return ss.first();} + public E last() {return ss.last();} } /** @@ -1147,7 +1187,7 @@ public class Collections { * @return an unmodifiable view of the specified list. */ public static List unmodifiableList(List list) { - return (list instanceof RandomAccess ? + return (list instanceof RandomAccess ? new UnmodifiableRandomAccessList(list) : new UnmodifiableList(list)); } @@ -1156,60 +1196,60 @@ public class Collections { * @serial include */ static class UnmodifiableList extends UnmodifiableCollection - implements List { + implements List { private static final long serialVersionUID = -283967356065247728L; - final List list; + final List list; + + UnmodifiableList(List list) { + super(list); + this.list = list; + } + + public boolean equals(Object o) {return o == this || list.equals(o);} + public int hashCode() {return list.hashCode();} + + public E get(int index) {return list.get(index);} + public E set(int index, E element) { + throw new UnsupportedOperationException(); + } + public void add(int index, E element) { + throw new UnsupportedOperationException(); + } + public E remove(int index) { + throw new UnsupportedOperationException(); + } + public int indexOf(Object o) {return list.indexOf(o);} + public int lastIndexOf(Object o) {return list.lastIndexOf(o);} + public boolean addAll(int index, Collection c) { + throw new UnsupportedOperationException(); + } + public ListIterator listIterator() {return listIterator(0);} - UnmodifiableList(List list) { - super(list); - this.list = list; - } - - public boolean equals(Object o) {return o == this || list.equals(o);} - public int hashCode() {return list.hashCode();} - - public E get(int index) {return list.get(index);} - public E set(int index, E element) { - throw new UnsupportedOperationException(); - } - public void add(int index, E element) { - throw new UnsupportedOperationException(); - } - public E remove(int index) { - throw new UnsupportedOperationException(); - } - public int indexOf(Object o) {return list.indexOf(o);} - public int lastIndexOf(Object o) {return list.lastIndexOf(o);} - public boolean addAll(int index, Collection c) { - throw new UnsupportedOperationException(); - } - public ListIterator listIterator() {return listIterator(0);} - - public ListIterator listIterator(final int index) { - return new ListIterator() { - private final ListIterator i - = list.listIterator(index); - - public boolean hasNext() {return i.hasNext();} - public E next() {return i.next();} - public boolean hasPrevious() {return i.hasPrevious();} - public E previous() {return i.previous();} - public int nextIndex() {return i.nextIndex();} - public int previousIndex() {return i.previousIndex();} + public ListIterator listIterator(final int index) { + return new ListIterator() { + private final ListIterator i + = list.listIterator(index); + + public boolean hasNext() {return i.hasNext();} + public E next() {return i.next();} + public boolean hasPrevious() {return i.hasPrevious();} + public E previous() {return i.previous();} + public int nextIndex() {return i.nextIndex();} + public int previousIndex() {return i.previousIndex();} - public void remove() { - throw new UnsupportedOperationException(); + public void remove() { + throw new UnsupportedOperationException(); } - public void set(E e) { - throw new UnsupportedOperationException(); + public void set(E e) { + throw new UnsupportedOperationException(); } - public void add(E e) { - throw new UnsupportedOperationException(); + public void add(E e) { + throw new UnsupportedOperationException(); } - }; - } + }; + } - public List subList(int fromIndex, int toIndex) { + public List subList(int fromIndex, int toIndex) { return new UnmodifiableList(list.subList(fromIndex, toIndex)); } @@ -1227,8 +1267,8 @@ public class Collections { */ private Object readResolve() { return (list instanceof RandomAccess - ? new UnmodifiableRandomAccessList(list) - : this); + ? new UnmodifiableRandomAccessList(list) + : this); } } @@ -1242,7 +1282,7 @@ public class Collections { super(list); } - public List subList(int fromIndex, int toIndex) { + public List subList(int fromIndex, int toIndex) { return new UnmodifiableRandomAccessList( list.subList(fromIndex, toIndex)); } @@ -1275,66 +1315,66 @@ public class Collections { * @return an unmodifiable view of the specified map. */ public static Map unmodifiableMap(Map m) { - return new UnmodifiableMap(m); + return new UnmodifiableMap(m); } /** * @serial include */ private static class UnmodifiableMap implements Map, Serializable { - private static final long serialVersionUID = -1034234728574286014L; + private static final long serialVersionUID = -1034234728574286014L; - private final Map m; + private final Map m; - UnmodifiableMap(Map m) { + UnmodifiableMap(Map m) { if (m==null) throw new NullPointerException(); this.m = m; } - public int size() {return m.size();} - public boolean isEmpty() {return m.isEmpty();} - public boolean containsKey(Object key) {return m.containsKey(key);} - public boolean containsValue(Object val) {return m.containsValue(val);} - public V get(Object key) {return m.get(key);} - - public V put(K key, V value) { - throw new UnsupportedOperationException(); - } - public V remove(Object key) { - throw new UnsupportedOperationException(); - } - public void putAll(Map m) { - throw new UnsupportedOperationException(); - } - public void clear() { - throw new UnsupportedOperationException(); - } - - private transient Set keySet = null; - private transient Set> entrySet = null; - private transient Collection values = null; - - public Set keySet() { - if (keySet==null) - keySet = unmodifiableSet(m.keySet()); - return keySet; - } - - public Set> entrySet() { - if (entrySet==null) - entrySet = new UnmodifiableEntrySet(m.entrySet()); - return entrySet; - } - - public Collection values() { - if (values==null) - values = unmodifiableCollection(m.values()); - return values; - } + public int size() {return m.size();} + public boolean isEmpty() {return m.isEmpty();} + public boolean containsKey(Object key) {return m.containsKey(key);} + public boolean containsValue(Object val) {return m.containsValue(val);} + public V get(Object key) {return m.get(key);} - public boolean equals(Object o) {return o == this || m.equals(o);} - public int hashCode() {return m.hashCode();} + public V put(K key, V value) { + throw new UnsupportedOperationException(); + } + public V remove(Object key) { + throw new UnsupportedOperationException(); + } + public void putAll(Map m) { + throw new UnsupportedOperationException(); + } + public void clear() { + throw new UnsupportedOperationException(); + } + + private transient Set keySet = null; + private transient Set> entrySet = null; + private transient Collection values = null; + + public Set keySet() { + if (keySet==null) + keySet = unmodifiableSet(m.keySet()); + return keySet; + } + + public Set> entrySet() { + if (entrySet==null) + entrySet = new UnmodifiableEntrySet(m.entrySet()); + return entrySet; + } + + public Collection values() { + if (values==null) + values = unmodifiableCollection(m.values()); + return values; + } + + public boolean equals(Object o) {return o == this || m.equals(o);} + public int hashCode() {return m.hashCode();} public String toString() {return m.toString();} /** @@ -1346,21 +1386,21 @@ public class Collections { * @serial include */ static class UnmodifiableEntrySet - extends UnmodifiableSet> { - private static final long serialVersionUID = 7854390611657943733L; + extends UnmodifiableSet> { + private static final long serialVersionUID = 7854390611657943733L; UnmodifiableEntrySet(Set> s) { super((Set)s); } public Iterator> iterator() { return new Iterator>() { - private final Iterator> i = c.iterator(); + private final Iterator> i = c.iterator(); public boolean hasNext() { return i.hasNext(); } - public Map.Entry next() { - return new UnmodifiableEntry(i.next()); + public Map.Entry next() { + return new UnmodifiableEntry(i.next()); } public void remove() { throw new UnsupportedOperationException(); @@ -1379,7 +1419,7 @@ public class Collections { // We don't pass a to c.toArray, to avoid window of // vulnerability wherein an unscrupulous multithreaded client // could get his hands on raw (unwrapped) Entries from c. - Object[] arr = c.toArray(a.length==0 ? a : Arrays.copyOf(a, 0)); + Object[] arr = c.toArray(a.length==0 ? a : Arrays.copyOf(a, 0)); for (int i=0; i((Map.Entry)arr[i]); @@ -1403,7 +1443,7 @@ public class Collections { if (!(o instanceof Map.Entry)) return false; return c.contains( - new UnmodifiableEntry((Map.Entry) o)); + new UnmodifiableEntry((Map.Entry) o)); } /** @@ -1412,9 +1452,9 @@ public class Collections { * when o is a Map.Entry, and calls o.setValue. */ public boolean containsAll(Collection coll) { - Iterator e = coll.iterator(); - while (e.hasNext()) - if (!contains(e.next())) // Invokes safe contains() above + Iterator it = coll.iterator(); + while (it.hasNext()) + if (!contains(it.next())) // Invokes safe contains() above return false; return true; } @@ -1442,12 +1482,12 @@ public class Collections { UnmodifiableEntry(Map.Entry e) {this.e = e;} - public K getKey() {return e.getKey();} - public V getValue() {return e.getValue();} + public K getKey() {return e.getKey();} + public V getValue() {return e.getValue();} public V setValue(V value) { throw new UnsupportedOperationException(); } - public int hashCode() {return e.hashCode();} + public int hashCode() {return e.hashCode();} public boolean equals(Object o) { if (!(o instanceof Map.Entry)) return false; @@ -1455,7 +1495,7 @@ public class Collections { return eq(e.getKey(), t.getKey()) && eq(e.getValue(), t.getValue()); } - public String toString() {return e.toString();} + public String toString() {return e.toString();} } } } @@ -1477,20 +1517,20 @@ public class Collections { * @return an unmodifiable view of the specified sorted map. */ public static SortedMap unmodifiableSortedMap(SortedMap m) { - return new UnmodifiableSortedMap(m); + return new UnmodifiableSortedMap(m); } /** * @serial include */ static class UnmodifiableSortedMap - extends UnmodifiableMap - implements SortedMap, Serializable { - private static final long serialVersionUID = -8806743815996713206L; + extends UnmodifiableMap + implements SortedMap, Serializable { + private static final long serialVersionUID = -8806743815996713206L; private final SortedMap sm; - UnmodifiableSortedMap(SortedMap m) {super(m); sm = m;} + UnmodifiableSortedMap(SortedMap m) {super(m); sm = m;} public Comparator comparator() {return sm.comparator();} @@ -1522,7 +1562,7 @@ public class Collections { *

      *  Collection c = Collections.synchronizedCollection(myCollection);
      *     ...
-     *  synchronized(c) {
+     *  synchronized (c) {
      *      Iterator i = c.iterator(); // Must be in the synchronized block
      *      while (i.hasNext())
      *         foo(i.next());
@@ -1543,80 +1583,80 @@ public class Collections {
      * @return a synchronized view of the specified collection.
      */
     public static  Collection synchronizedCollection(Collection c) {
-	return new SynchronizedCollection(c);
+        return new SynchronizedCollection(c);
     }
 
     static  Collection synchronizedCollection(Collection c, Object mutex) {
-	return new SynchronizedCollection(c, mutex);
+        return new SynchronizedCollection(c, mutex);
     }
 
     /**
      * @serial include
      */
     static class SynchronizedCollection implements Collection, Serializable {
-	private static final long serialVersionUID = 3053995032091335093L;
+        private static final long serialVersionUID = 3053995032091335093L;
 
-	final Collection c;  // Backing Collection
-	final Object mutex;     // Object on which to synchronize
+        final Collection c;  // Backing Collection
+        final Object mutex;     // Object on which to synchronize
 
-	SynchronizedCollection(Collection c) {
+        SynchronizedCollection(Collection c) {
             if (c==null)
                 throw new NullPointerException();
-	    this.c = c;
+            this.c = c;
             mutex = this;
         }
-	SynchronizedCollection(Collection c, Object mutex) {
-	    this.c = c;
+        SynchronizedCollection(Collection c, Object mutex) {
+            this.c = c;
             this.mutex = mutex;
         }
 
-	public int size() {
-	    synchronized(mutex) {return c.size();}
+        public int size() {
+            synchronized (mutex) {return c.size();}
         }
-	public boolean isEmpty() {
-	    synchronized(mutex) {return c.isEmpty();}
+        public boolean isEmpty() {
+            synchronized (mutex) {return c.isEmpty();}
         }
-	public boolean contains(Object o) {
-	    synchronized(mutex) {return c.contains(o);}
+        public boolean contains(Object o) {
+            synchronized (mutex) {return c.contains(o);}
         }
-	public Object[] toArray() {
-	    synchronized(mutex) {return c.toArray();}
+        public Object[] toArray() {
+            synchronized (mutex) {return c.toArray();}
         }
-	public  T[] toArray(T[] a) {
-	    synchronized(mutex) {return c.toArray(a);}
+        public  T[] toArray(T[] a) {
+            synchronized (mutex) {return c.toArray(a);}
         }
 
-	public Iterator iterator() {
+        public Iterator iterator() {
             return c.iterator(); // Must be manually synched by user!
         }
 
-	public boolean add(E e) {
-	    synchronized(mutex) {return c.add(e);}
+        public boolean add(E e) {
+            synchronized (mutex) {return c.add(e);}
         }
-	public boolean remove(Object o) {
-	    synchronized(mutex) {return c.remove(o);}
+        public boolean remove(Object o) {
+            synchronized (mutex) {return c.remove(o);}
         }
 
-	public boolean containsAll(Collection coll) {
-	    synchronized(mutex) {return c.containsAll(coll);}
+        public boolean containsAll(Collection coll) {
+            synchronized (mutex) {return c.containsAll(coll);}
         }
-	public boolean addAll(Collection coll) {
-	    synchronized(mutex) {return c.addAll(coll);}
+        public boolean addAll(Collection coll) {
+            synchronized (mutex) {return c.addAll(coll);}
         }
-	public boolean removeAll(Collection coll) {
-	    synchronized(mutex) {return c.removeAll(coll);}
+        public boolean removeAll(Collection coll) {
+            synchronized (mutex) {return c.removeAll(coll);}
         }
-	public boolean retainAll(Collection coll) {
-	    synchronized(mutex) {return c.retainAll(coll);}
+        public boolean retainAll(Collection coll) {
+            synchronized (mutex) {return c.retainAll(coll);}
         }
-	public void clear() {
-	    synchronized(mutex) {c.clear();}
+        public void clear() {
+            synchronized (mutex) {c.clear();}
         }
-	public String toString() {
-	    synchronized(mutex) {return c.toString();}
+        public String toString() {
+            synchronized (mutex) {return c.toString();}
         }
         private void writeObject(ObjectOutputStream s) throws IOException {
-	    synchronized(mutex) {s.defaultWriteObject();}
+            synchronized (mutex) {s.defaultWriteObject();}
         }
     }
 
@@ -1631,7 +1671,7 @@ public class Collections {
      * 
      *  Set s = Collections.synchronizedSet(new HashSet());
      *      ...
-     *  synchronized(s) {
+     *  synchronized (s) {
      *      Iterator i = s.iterator(); // Must be in the synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -1646,33 +1686,33 @@ public class Collections {
      * @return a synchronized view of the specified set.
      */
     public static  Set synchronizedSet(Set s) {
-	return new SynchronizedSet(s);
+        return new SynchronizedSet(s);
     }
 
     static  Set synchronizedSet(Set s, Object mutex) {
-	return new SynchronizedSet(s, mutex);
+        return new SynchronizedSet(s, mutex);
     }
 
     /**
      * @serial include
      */
     static class SynchronizedSet
-	  extends SynchronizedCollection
-	  implements Set {
-	private static final long serialVersionUID = 487447009682186044L;
+          extends SynchronizedCollection
+          implements Set {
+        private static final long serialVersionUID = 487447009682186044L;
 
-	SynchronizedSet(Set s) {
+        SynchronizedSet(Set s) {
             super(s);
         }
-	SynchronizedSet(Set s, Object mutex) {
+        SynchronizedSet(Set s, Object mutex) {
             super(s, mutex);
         }
 
-	public boolean equals(Object o) {
-	    synchronized(mutex) {return c.equals(o);}
+        public boolean equals(Object o) {
+            synchronized (mutex) {return c.equals(o);}
         }
-	public int hashCode() {
-	    synchronized(mutex) {return c.hashCode();}
+        public int hashCode() {
+            synchronized (mutex) {return c.hashCode();}
         }
     }
 
@@ -1688,7 +1728,7 @@ public class Collections {
      * 
      *  SortedSet s = Collections.synchronizedSortedSet(new TreeSet());
      *      ...
-     *  synchronized(s) {
+     *  synchronized (s) {
      *      Iterator i = s.iterator(); // Must be in the synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -1699,7 +1739,7 @@ public class Collections {
      *  SortedSet s = Collections.synchronizedSortedSet(new TreeSet());
      *  SortedSet s2 = s.headSet(foo);
      *      ...
-     *  synchronized(s) {  // Note: s, not s2!!!
+     *  synchronized (s) {  // Note: s, not s2!!!
      *      Iterator i = s2.iterator(); // Must be in the synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -1714,55 +1754,55 @@ public class Collections {
      * @return a synchronized view of the specified sorted set.
      */
     public static  SortedSet synchronizedSortedSet(SortedSet s) {
-	return new SynchronizedSortedSet(s);
+        return new SynchronizedSortedSet(s);
     }
 
     /**
      * @serial include
      */
     static class SynchronizedSortedSet
-	extends SynchronizedSet
-	implements SortedSet
+        extends SynchronizedSet
+        implements SortedSet
     {
-	private static final long serialVersionUID = 8695801310862127406L;
+        private static final long serialVersionUID = 8695801310862127406L;
 
-        final private SortedSet ss;
+        private final SortedSet ss;
 
-	SynchronizedSortedSet(SortedSet s) {
+        SynchronizedSortedSet(SortedSet s) {
             super(s);
             ss = s;
         }
-	SynchronizedSortedSet(SortedSet s, Object mutex) {
+        SynchronizedSortedSet(SortedSet s, Object mutex) {
             super(s, mutex);
             ss = s;
         }
 
-	public Comparator comparator() {
-	    synchronized(mutex) {return ss.comparator();}
+        public Comparator comparator() {
+            synchronized (mutex) {return ss.comparator();}
         }
 
         public SortedSet subSet(E fromElement, E toElement) {
-	    synchronized(mutex) {
+            synchronized (mutex) {
                 return new SynchronizedSortedSet(
                     ss.subSet(fromElement, toElement), mutex);
             }
         }
         public SortedSet headSet(E toElement) {
-	    synchronized(mutex) {
+            synchronized (mutex) {
                 return new SynchronizedSortedSet(ss.headSet(toElement), mutex);
             }
         }
         public SortedSet tailSet(E fromElement) {
-	    synchronized(mutex) {
+            synchronized (mutex) {
                return new SynchronizedSortedSet(ss.tailSet(fromElement),mutex);
             }
         }
 
         public E first() {
-	    synchronized(mutex) {return ss.first();}
+            synchronized (mutex) {return ss.first();}
         }
         public E last() {
-	    synchronized(mutex) {return ss.last();}
+            synchronized (mutex) {return ss.last();}
         }
     }
 
@@ -1777,7 +1817,7 @@ public class Collections {
      * 
      *  List list = Collections.synchronizedList(new ArrayList());
      *      ...
-     *  synchronized(list) {
+     *  synchronized (list) {
      *      Iterator i = list.iterator(); // Must be in synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -1792,13 +1832,13 @@ public class Collections {
      * @return a synchronized view of the specified list.
      */
     public static  List synchronizedList(List list) {
-	return (list instanceof RandomAccess ?
+        return (list instanceof RandomAccess ?
                 new SynchronizedRandomAccessList(list) :
                 new SynchronizedList(list));
     }
 
     static  List synchronizedList(List list, Object mutex) {
-	return (list instanceof RandomAccess ?
+        return (list instanceof RandomAccess ?
                 new SynchronizedRandomAccessList(list, mutex) :
                 new SynchronizedList(list, mutex));
     }
@@ -1807,62 +1847,62 @@ public class Collections {
      * @serial include
      */
     static class SynchronizedList
-	extends SynchronizedCollection
-	implements List {
+        extends SynchronizedCollection
+        implements List {
         private static final long serialVersionUID = -7754090372962971524L;
 
-	final List list;
+        final List list;
 
-	SynchronizedList(List list) {
-	    super(list);
-	    this.list = list;
-	}
-	SynchronizedList(List list, Object mutex) {
+        SynchronizedList(List list) {
+            super(list);
+            this.list = list;
+        }
+        SynchronizedList(List list, Object mutex) {
             super(list, mutex);
-	    this.list = list;
+            this.list = list;
         }
 
-	public boolean equals(Object o) {
-	    synchronized(mutex) {return list.equals(o);}
+        public boolean equals(Object o) {
+            synchronized (mutex) {return list.equals(o);}
         }
-	public int hashCode() {
-	    synchronized(mutex) {return list.hashCode();}
+        public int hashCode() {
+            synchronized (mutex) {return list.hashCode();}
         }
 
-	public E get(int index) {
-	    synchronized(mutex) {return list.get(index);}
+        public E get(int index) {
+            synchronized (mutex) {return list.get(index);}
         }
-	public E set(int index, E element) {
-	    synchronized(mutex) {return list.set(index, element);}
+        public E set(int index, E element) {
+            synchronized (mutex) {return list.set(index, element);}
         }
-	public void add(int index, E element) {
-	    synchronized(mutex) {list.add(index, element);}
+        public void add(int index, E element) {
+            synchronized (mutex) {list.add(index, element);}
         }
-	public E remove(int index) {
-	    synchronized(mutex) {return list.remove(index);}
+        public E remove(int index) {
+            synchronized (mutex) {return list.remove(index);}
         }
 
-	public int indexOf(Object o) {
-	    synchronized(mutex) {return list.indexOf(o);}
+        public int indexOf(Object o) {
+            synchronized (mutex) {return list.indexOf(o);}
         }
-	public int lastIndexOf(Object o) {
-	    synchronized(mutex) {return list.lastIndexOf(o);}
+        public int lastIndexOf(Object o) {
+            synchronized (mutex) {return list.lastIndexOf(o);}
         }
 
-	public boolean addAll(int index, Collection c) {
-	    synchronized(mutex) {return list.addAll(index, c);}
+        public boolean addAll(int index, Collection c) {
+            synchronized (mutex) {return list.addAll(index, c);}
         }
 
-	public ListIterator listIterator() {
-	    return list.listIterator(); // Must be manually synched by user
+        public ListIterator listIterator() {
+            return list.listIterator(); // Must be manually synched by user
         }
 
-	public ListIterator listIterator(int index) {
-	    return list.listIterator(index); // Must be manually synched by user
+        public ListIterator listIterator(int index) {
+            return list.listIterator(index); // Must be manually synched by user
         }
 
-	public List subList(int fromIndex, int toIndex) {
-	    synchronized(mutex) {
+        public List subList(int fromIndex, int toIndex) {
+            synchronized (mutex) {
                 return new SynchronizedList(list.subList(fromIndex, toIndex),
                                             mutex);
             }
@@ -1882,8 +1922,8 @@ public class Collections {
          */
         private Object readResolve() {
             return (list instanceof RandomAccess
-		    ? new SynchronizedRandomAccessList(list)
-		    : this);
+                    ? new SynchronizedRandomAccessList(list)
+                    : this);
         }
     }
 
@@ -1891,19 +1931,19 @@ public class Collections {
      * @serial include
      */
     static class SynchronizedRandomAccessList
-	extends SynchronizedList
-	implements RandomAccess {
+        extends SynchronizedList
+        implements RandomAccess {
 
         SynchronizedRandomAccessList(List list) {
             super(list);
         }
 
-	SynchronizedRandomAccessList(List list, Object mutex) {
+        SynchronizedRandomAccessList(List list, Object mutex) {
             super(list, mutex);
         }
 
-	public List subList(int fromIndex, int toIndex) {
-	    synchronized(mutex) {
+        public List subList(int fromIndex, int toIndex) {
+            synchronized (mutex) {
                 return new SynchronizedRandomAccessList(
                     list.subList(fromIndex, toIndex), mutex);
             }
@@ -1935,7 +1975,7 @@ public class Collections {
      *      ...
      *  Set s = m.keySet();  // Needn't be in synchronized block
      *      ...
-     *  synchronized(m) {  // Synchronizing on m, not s!
+     *  synchronized (m) {  // Synchronizing on m, not s!
      *      Iterator i = s.iterator(); // Must be in synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -1950,99 +1990,99 @@ public class Collections {
      * @return a synchronized view of the specified map.
      */
     public static  Map synchronizedMap(Map m) {
-	return new SynchronizedMap(m);
+        return new SynchronizedMap(m);
     }
 
     /**
      * @serial include
      */
     private static class SynchronizedMap
-	implements Map, Serializable {
-	private static final long serialVersionUID = 1978198479659022715L;
+        implements Map, Serializable {
+        private static final long serialVersionUID = 1978198479659022715L;
 
-	private final Map m;     // Backing Map
-        final Object      mutex;	// Object on which to synchronize
+        private final Map m;     // Backing Map
+        final Object      mutex;        // Object on which to synchronize
 
-	SynchronizedMap(Map m) {
+        SynchronizedMap(Map m) {
             if (m==null)
                 throw new NullPointerException();
             this.m = m;
             mutex = this;
         }
 
-	SynchronizedMap(Map m, Object mutex) {
+        SynchronizedMap(Map m, Object mutex) {
             this.m = m;
             this.mutex = mutex;
         }
 
-	public int size() {
-	    synchronized(mutex) {return m.size();}
+        public int size() {
+            synchronized (mutex) {return m.size();}
         }
-	public boolean isEmpty() {
-	    synchronized(mutex) {return m.isEmpty();}
+        public boolean isEmpty() {
+            synchronized (mutex) {return m.isEmpty();}
         }
-	public boolean containsKey(Object key) {
-	    synchronized(mutex) {return m.containsKey(key);}
+        public boolean containsKey(Object key) {
+            synchronized (mutex) {return m.containsKey(key);}
         }
-	public boolean containsValue(Object value) {
-	    synchronized(mutex) {return m.containsValue(value);}
+        public boolean containsValue(Object value) {
+            synchronized (mutex) {return m.containsValue(value);}
         }
-	public V get(Object key) {
-	    synchronized(mutex) {return m.get(key);}
+        public V get(Object key) {
+            synchronized (mutex) {return m.get(key);}
         }
 
-	public V put(K key, V value) {
-	    synchronized(mutex) {return m.put(key, value);}
+        public V put(K key, V value) {
+            synchronized (mutex) {return m.put(key, value);}
+        }
+        public V remove(Object key) {
+            synchronized (mutex) {return m.remove(key);}
         }
-	public V remove(Object key) {
-	    synchronized(mutex) {return m.remove(key);}
+        public void putAll(Map map) {
+            synchronized (mutex) {m.putAll(map);}
         }
-	public void putAll(Map map) {
-	    synchronized(mutex) {m.putAll(map);}
+        public void clear() {
+            synchronized (mutex) {m.clear();}
         }
-	public void clear() {
-	    synchronized(mutex) {m.clear();}
-	}
 
-	private transient Set keySet = null;
-	private transient Set> entrySet = null;
-	private transient Collection values = null;
+        private transient Set keySet = null;
+        private transient Set> entrySet = null;
+        private transient Collection values = null;
 
-	public Set keySet() {
-            synchronized(mutex) {
+        public Set keySet() {
+            synchronized (mutex) {
                 if (keySet==null)
                     keySet = new SynchronizedSet(m.keySet(), mutex);
                 return keySet;
             }
-	}
+        }
 
-	public Set> entrySet() {
-            synchronized(mutex) {
+        public Set> entrySet() {
+            synchronized (mutex) {
                 if (entrySet==null)
                     entrySet = new SynchronizedSet>(m.entrySet(), mutex);
                 return entrySet;
             }
-	}
+        }
 
-	public Collection values() {
-            synchronized(mutex) {
+        public Collection values() {
+            synchronized (mutex) {
                 if (values==null)
                     values = new SynchronizedCollection(m.values(), mutex);
                 return values;
             }
         }
 
-	public boolean equals(Object o) {
-            synchronized(mutex) {return m.equals(o);}
+        public boolean equals(Object o) {
+            synchronized (mutex) {return m.equals(o);}
         }
-	public int hashCode() {
-            synchronized(mutex) {return m.hashCode();}
+        public int hashCode() {
+            synchronized (mutex) {return m.hashCode();}
         }
-	public String toString() {
-	    synchronized(mutex) {return m.toString();}
+        public String toString() {
+            synchronized (mutex) {return m.toString();}
         }
         private void writeObject(ObjectOutputStream s) throws IOException {
-	    synchronized(mutex) {s.defaultWriteObject();}
+            synchronized (mutex) {s.defaultWriteObject();}
         }
     }
 
@@ -2061,7 +2101,7 @@ public class Collections {
      *      ...
      *  Set s = m.keySet();  // Needn't be in synchronized block
      *      ...
-     *  synchronized(m) {  // Synchronizing on m, not s!
+     *  synchronized (m) {  // Synchronizing on m, not s!
      *      Iterator i = s.iterator(); // Must be in synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -2074,7 +2114,7 @@ public class Collections {
      *      ...
      *  Set s2 = m2.keySet();  // Needn't be in synchronized block
      *      ...
-     *  synchronized(m) {  // Synchronizing on m, not m2 or s2!
+     *  synchronized (m) {  // Synchronizing on m, not m2 or s2!
      *      Iterator i = s.iterator(); // Must be in synchronized block
      *      while (i.hasNext())
      *          foo(i.next());
@@ -2089,7 +2129,7 @@ public class Collections {
      * @return a synchronized view of the specified sorted map.
      */
     public static  SortedMap synchronizedSortedMap(SortedMap m) {
-	return new SynchronizedSortedMap(m);
+        return new SynchronizedSortedMap(m);
     }
 
 
@@ -2097,48 +2137,48 @@ public class Collections {
      * @serial include
      */
     static class SynchronizedSortedMap
-	extends SynchronizedMap
-	implements SortedMap
+        extends SynchronizedMap
+        implements SortedMap
     {
-	private static final long serialVersionUID = -8798146769416483793L;
+        private static final long serialVersionUID = -8798146769416483793L;
 
         private final SortedMap sm;
 
-	SynchronizedSortedMap(SortedMap m) {
+        SynchronizedSortedMap(SortedMap m) {
             super(m);
             sm = m;
         }
-	SynchronizedSortedMap(SortedMap m, Object mutex) {
+        SynchronizedSortedMap(SortedMap m, Object mutex) {
             super(m, mutex);
             sm = m;
         }
 
-	public Comparator comparator() {
-	    synchronized(mutex) {return sm.comparator();}
+        public Comparator comparator() {
+            synchronized (mutex) {return sm.comparator();}
         }
 
         public SortedMap subMap(K fromKey, K toKey) {
-	    synchronized(mutex) {
+            synchronized (mutex) {
                 return new SynchronizedSortedMap(
                     sm.subMap(fromKey, toKey), mutex);
             }
         }
         public SortedMap headMap(K toKey) {
-	    synchronized(mutex) {
+            synchronized (mutex) {
                 return new SynchronizedSortedMap(sm.headMap(toKey), mutex);
             }
         }
         public SortedMap tailMap(K fromKey) {
-	    synchronized(mutex) {
+            synchronized (mutex) {
                return new SynchronizedSortedMap(sm.tailMap(fromKey),mutex);
             }
         }
 
         public K firstKey() {
-	    synchronized(mutex) {return sm.firstKey();}
+            synchronized (mutex) {return sm.firstKey();}
         }
         public K lastKey() {
-	    synchronized(mutex) {return sm.lastKey();}
+            synchronized (mutex) {return sm.lastKey();}
         }
     }
 
@@ -2211,7 +2251,7 @@ public class Collections {
 
     @SuppressWarnings("unchecked")
     static  T[] zeroLengthArray(Class type) {
-	return (T[]) Array.newInstance(type, 0);
+        return (T[]) Array.newInstance(type, 0);
     }
 
     /**
@@ -2228,10 +2268,10 @@ public class Collections {
                 throw new ClassCastException(badElementMsg(o));
         }
 
-	private String badElementMsg(Object o) {
-	    return "Attempt to insert " + o.getClass() +
-		" element into collection with element type " + type;
-	}
+        private String badElementMsg(Object o) {
+            return "Attempt to insert " + o.getClass() +
+                " element into collection with element type " + type;
+        }
 
         CheckedCollection(Collection c, Class type) {
             if (c==null || type == null)
@@ -2249,7 +2289,7 @@ public class Collections {
         public boolean remove(Object o)   { return c.remove(o); }
         public void clear()               {        c.clear(); }
 
-	public boolean containsAll(Collection coll) {
+        public boolean containsAll(Collection coll) {
             return c.containsAll(coll);
         }
         public boolean removeAll(Collection coll) {
@@ -2260,54 +2300,54 @@ public class Collections {
         }
 
         public Iterator iterator() {
-	    final Iterator it = c.iterator();
-	    return new Iterator() {
-		public boolean hasNext() { return it.hasNext(); }
-		public E next()          { return it.next(); }
-		public void remove()     {        it.remove(); }};
-	}
+            final Iterator it = c.iterator();
+            return new Iterator() {
+                public boolean hasNext() { return it.hasNext(); }
+                public E next()          { return it.next(); }
+                public void remove()     {        it.remove(); }};
+        }
 
-	public boolean add(E e) {
+        public boolean add(E e) {
             typeCheck(e);
             return c.add(e);
         }
 
         private E[] zeroLengthElementArray = null; // Lazily initialized
 
-	private E[] zeroLengthElementArray() {
-	    return zeroLengthElementArray != null ? zeroLengthElementArray :
-		(zeroLengthElementArray = zeroLengthArray(type));
-	}
-
-	@SuppressWarnings("unchecked")
-	Collection checkedCopyOf(Collection coll) {
-	    Object[] a = null;
-	    try {
-		E[] z = zeroLengthElementArray();
-		a = coll.toArray(z);
-		// Defend against coll violating the toArray contract
-		if (a.getClass() != z.getClass())
-		    a = Arrays.copyOf(a, a.length, z.getClass());
-	    } catch (ArrayStoreException ignore) {
-		// To get better and consistent diagnostics,
-		// we call typeCheck explicitly on each element.
-		// We call clone() to defend against coll retaining a
-		// reference to the returned array and storing a bad
-		// element into it after it has been type checked.
-		a = coll.toArray().clone();
-		for (Object o : a)
-		    typeCheck(o);
-	    }
-	    // A slight abuse of the type system, but safe here.
-	    return (Collection) Arrays.asList(a);
-	}
+        private E[] zeroLengthElementArray() {
+            return zeroLengthElementArray != null ? zeroLengthElementArray :
+                (zeroLengthElementArray = zeroLengthArray(type));
+        }
+
+        @SuppressWarnings("unchecked")
+        Collection checkedCopyOf(Collection coll) {
+            Object[] a = null;
+            try {
+                E[] z = zeroLengthElementArray();
+                a = coll.toArray(z);
+                // Defend against coll violating the toArray contract
+                if (a.getClass() != z.getClass())
+                    a = Arrays.copyOf(a, a.length, z.getClass());
+            } catch (ArrayStoreException ignore) {
+                // To get better and consistent diagnostics,
+                // we call typeCheck explicitly on each element.
+                // We call clone() to defend against coll retaining a
+                // reference to the returned array and storing a bad
+                // element into it after it has been type checked.
+                a = coll.toArray().clone();
+                for (Object o : a)
+                    typeCheck(o);
+            }
+            // A slight abuse of the type system, but safe here.
+            return (Collection) Arrays.asList(a);
+        }
 
         public boolean addAll(Collection coll) {
-	    // Doing things this way insulates us from concurrent changes
-	    // in the contents of coll and provides all-or-nothing
-	    // semantics (which we wouldn't get if we type-checked each
-	    // element as we added it)
-	    return c.addAll(checkedCopyOf(coll));
+            // Doing things this way insulates us from concurrent changes
+            // in the contents of coll and provides all-or-nothing
+            // semantics (which we wouldn't get if we type-checked each
+            // element as we added it)
+            return c.addAll(checkedCopyOf(coll));
         }
     }
 
@@ -2452,8 +2492,8 @@ public class Collections {
      * @serial include
      */
     static class CheckedList
-	extends CheckedCollection
-	implements List
+        extends CheckedCollection
+        implements List
     {
         private static final long serialVersionUID = 65247728283967356L;
         final List list;
@@ -2486,9 +2526,9 @@ public class Collections {
         public ListIterator listIterator()   { return listIterator(0); }
 
         public ListIterator listIterator(final int index) {
-	    final ListIterator i = list.listIterator(index);
+            final ListIterator i = list.listIterator(index);
 
-	    return new ListIterator() {
+            return new ListIterator() {
                 public boolean hasNext()     { return i.hasNext(); }
                 public E next()              { return i.next(); }
                 public boolean hasPrevious() { return i.hasPrevious(); }
@@ -2567,7 +2607,7 @@ public class Collections {
      * @since 1.5
      */
     public static  Map checkedMap(Map m,
-					      Class keyType,
+                                              Class keyType,
                                               Class valueType) {
         return new CheckedMap(m, keyType, valueType);
     }
@@ -2577,7 +2617,7 @@ public class Collections {
      * @serial include
      */
     private static class CheckedMap
-	implements Map, Serializable
+        implements Map, Serializable
     {
         private static final long serialVersionUID = 5742860141034234728L;
 
@@ -2593,15 +2633,15 @@ public class Collections {
                 throw new ClassCastException(badValueMsg(value));
         }
 
-	private String badKeyMsg(Object key) {
-	    return "Attempt to insert " + key.getClass() +
-		" key into map with key type " + keyType;
-	}
-
-	private String badValueMsg(Object value) {
-	    return "Attempt to insert " + value.getClass() +
-		" value into map with value type " + valueType;
-	}
+        private String badKeyMsg(Object key) {
+            return "Attempt to insert " + key.getClass() +
+                " key into map with key type " + keyType;
+        }
+
+        private String badValueMsg(Object value) {
+            return "Attempt to insert " + value.getClass() +
+                " value into map with value type " + valueType;
+        }
 
         CheckedMap(Map m, Class keyType, Class valueType) {
             if (m == null || keyType == null || valueType == null)
@@ -2629,27 +2669,27 @@ public class Collections {
             return m.put(key, value);
         }
 
-	@SuppressWarnings("unchecked")
-	public void putAll(Map t) {
-	    // Satisfy the following goals:
-	    // - good diagnostics in case of type mismatch
-	    // - all-or-nothing semantics
-	    // - protection from malicious t
-	    // - correct behavior if t is a concurrent map
-	    Object[] entries = t.entrySet().toArray();
-	    List> checked =
-		new ArrayList>(entries.length);
-	    for (Object o : entries) {
-		Map.Entry e = (Map.Entry) o;
-		Object k = e.getKey();
-		Object v = e.getValue();
-		typeCheck(k, v);
-		checked.add(
-		    new AbstractMap.SimpleImmutableEntry((K) k, (V) v));
-	    }
-	    for (Map.Entry e : checked)
-		m.put(e.getKey(), e.getValue());
-	}
+        @SuppressWarnings("unchecked")
+        public void putAll(Map t) {
+            // Satisfy the following goals:
+            // - good diagnostics in case of type mismatch
+            // - all-or-nothing semantics
+            // - protection from malicious t
+            // - correct behavior if t is a concurrent map
+            Object[] entries = t.entrySet().toArray();
+            List> checked =
+                new ArrayList>(entries.length);
+            for (Object o : entries) {
+                Map.Entry e = (Map.Entry) o;
+                Object k = e.getKey();
+                Object v = e.getValue();
+                typeCheck(k, v);
+                checked.add(
+                    new AbstractMap.SimpleImmutableEntry((K) k, (V) v));
+            }
+            for (Map.Entry e : checked)
+                m.put(e.getKey(), e.getValue());
+        }
 
         private transient Set> entrySet = null;
 
@@ -2690,10 +2730,10 @@ public class Collections {
             }
 
             public Iterator> iterator() {
-		final Iterator> i = s.iterator();
-		final Class valueType = this.valueType;
+                final Iterator> i = s.iterator();
+                final Class valueType = this.valueType;
 
-		return new Iterator>() {
+                return new Iterator>() {
                     public boolean hasNext() { return i.hasNext(); }
                     public void remove()     { i.remove(); }
 
@@ -2703,7 +2743,7 @@ public class Collections {
                 };
             }
 
-	    @SuppressWarnings("unchecked")
+            @SuppressWarnings("unchecked")
             public Object[] toArray() {
                 Object[] source = s.toArray();
 
@@ -2717,11 +2757,11 @@ public class Collections {
 
                 for (int i = 0; i < source.length; i++)
                     dest[i] = checkedEntry((Map.Entry)source[i],
-					   valueType);
+                                           valueType);
                 return dest;
             }
 
-	    @SuppressWarnings("unchecked")
+            @SuppressWarnings("unchecked")
             public  T[] toArray(T[] a) {
                 // We don't pass a to s.toArray, to avoid window of
                 // vulnerability wherein an unscrupulous multithreaded client
@@ -2730,7 +2770,7 @@ public class Collections {
 
                 for (int i=0; i)arr[i],
-					      valueType);
+                                              valueType);
                 if (arr.length > a.length)
                     return arr;
 
@@ -2749,9 +2789,9 @@ public class Collections {
             public boolean contains(Object o) {
                 if (!(o instanceof Map.Entry))
                     return false;
-		Map.Entry e = (Map.Entry) o;
-		return s.contains(
-		    (e instanceof CheckedEntry) ? e : checkedEntry(e, valueType));
+                Map.Entry e = (Map.Entry) o;
+                return s.contains(
+                    (e instanceof CheckedEntry) ? e : checkedEntry(e, valueType));
             }
 
             /**
@@ -2760,36 +2800,36 @@ public class Collections {
              * method senses when o is a Map.Entry, and calls o.setValue.
              */
             public boolean containsAll(Collection c) {
-		for (Object o : c)
+                for (Object o : c)
                     if (!contains(o)) // Invokes safe contains() above
                         return false;
                 return true;
             }
 
-	    public boolean remove(Object o) {
+            public boolean remove(Object o) {
                 if (!(o instanceof Map.Entry))
                     return false;
-		return s.remove(new AbstractMap.SimpleImmutableEntry
-				((Map.Entry)o));
-	    }
-
-	    public boolean removeAll(Collection c) {
-		return batchRemove(c, false);
-            }
-	    public boolean retainAll(Collection c) {
-		return batchRemove(c, true);
-            }
-	    private boolean batchRemove(Collection c, boolean complement) {
-		boolean modified = false;
-		Iterator> it = iterator();
-		while (it.hasNext()) {
-		    if (c.contains(it.next()) != complement) {
-			it.remove();
-			modified = true;
-		    }
-		}
-		return modified;
-	    }
+                return s.remove(new AbstractMap.SimpleImmutableEntry
+                                ((Map.Entry)o));
+            }
+
+            public boolean removeAll(Collection c) {
+                return batchRemove(c, false);
+            }
+            public boolean retainAll(Collection c) {
+                return batchRemove(c, true);
+            }
+            private boolean batchRemove(Collection c, boolean complement) {
+                boolean modified = false;
+                Iterator> it = iterator();
+                while (it.hasNext()) {
+                    if (c.contains(it.next()) != complement) {
+                        it.remove();
+                        modified = true;
+                    }
+                }
+                return modified;
+            }
 
             public boolean equals(Object o) {
                 if (o == this)
@@ -2798,13 +2838,13 @@ public class Collections {
                     return false;
                 Set that = (Set) o;
                 return that.size() == s.size()
-		    && containsAll(that); // Invokes safe containsAll() above
+                    && containsAll(that); // Invokes safe containsAll() above
             }
 
-	    static  CheckedEntry checkedEntry(Map.Entry e,
-							    Class valueType) {
-		return new CheckedEntry(e, valueType);
-	    }
+            static  CheckedEntry checkedEntry(Map.Entry e,
+                                                            Class valueType) {
+                return new CheckedEntry(e, valueType);
+            }
 
             /**
              * This "wrapper class" serves two purposes: it prevents
@@ -2833,18 +2873,18 @@ public class Collections {
                     return e.setValue(value);
                 }
 
-		private String badValueMsg(Object value) {
-		    return "Attempt to insert " + value.getClass() +
-			" value into map with value type " + valueType;
-		}
+                private String badValueMsg(Object value) {
+                    return "Attempt to insert " + value.getClass() +
+                        " value into map with value type " + valueType;
+                }
 
                 public boolean equals(Object o) {
-		    if (o == this)
-			return true;
+                    if (o == this)
+                        return true;
                     if (!(o instanceof Map.Entry))
                         return false;
                     return e.equals(new AbstractMap.SimpleImmutableEntry
-				    ((Map.Entry)o));
+                                    ((Map.Entry)o));
                 }
             }
         }
@@ -2912,7 +2952,7 @@ public class Collections {
 
         public SortedMap subMap(K fromKey, K toKey) {
             return checkedSortedMap(sm.subMap(fromKey, toKey),
-				    keyType, valueType);
+                                    keyType, valueType);
         }
         public SortedMap headMap(K toKey) {
             return checkedSortedMap(sm.headMap(toKey), keyType, valueType);
@@ -2948,16 +2988,16 @@ public class Collections {
      */
     @SuppressWarnings("unchecked")
     public static  Iterator emptyIterator() {
-	return (Iterator) EmptyIterator.EMPTY_ITERATOR;
+        return (Iterator) EmptyIterator.EMPTY_ITERATOR;
     }
 
     private static class EmptyIterator implements Iterator {
-	static final EmptyIterator EMPTY_ITERATOR
-	    = new EmptyIterator();
+        static final EmptyIterator EMPTY_ITERATOR
+            = new EmptyIterator();
 
-	public boolean hasNext() { return false; }
-	public E next() { throw new NoSuchElementException(); }
-	public void remove() { throw new IllegalStateException(); }
+        public boolean hasNext() { return false; }
+        public E next() { throw new NoSuchElementException(); }
+        public void remove() { throw new IllegalStateException(); }
     }
 
     /**
@@ -2994,22 +3034,22 @@ public class Collections {
      */
     @SuppressWarnings("unchecked")
     public static  ListIterator emptyListIterator() {
-	return (ListIterator) EmptyListIterator.EMPTY_ITERATOR;
+        return (ListIterator) EmptyListIterator.EMPTY_ITERATOR;
     }
 
     private static class EmptyListIterator
-	extends EmptyIterator
-	implements ListIterator
+        extends EmptyIterator
+        implements ListIterator
     {
-	static final EmptyListIterator EMPTY_ITERATOR
-	    = new EmptyListIterator();
+        static final EmptyListIterator EMPTY_ITERATOR
+            = new EmptyListIterator();
 
-	public boolean hasPrevious() { return false; }
-	public E previous() { throw new NoSuchElementException(); }
-	public int nextIndex()     { return 0; }
-	public int previousIndex() { return -1; }
-	public void set(E e) { throw new IllegalStateException(); }
-	public void add(E e) { throw new UnsupportedOperationException(); }
+        public boolean hasPrevious() { return false; }
+        public E previous() { throw new NoSuchElementException(); }
+        public int nextIndex()     { return 0; }
+        public int previousIndex() { return -1; }
+        public void set(E e) { throw new IllegalStateException(); }
+        public void add(E e) { throw new UnsupportedOperationException(); }
     }
 
     /**
@@ -3033,15 +3073,15 @@ public class Collections {
      */
     @SuppressWarnings("unchecked")
     public static  Enumeration emptyEnumeration() {
-	return (Enumeration) EmptyEnumeration.EMPTY_ENUMERATION;
+        return (Enumeration) EmptyEnumeration.EMPTY_ENUMERATION;
     }
 
     private static class EmptyEnumeration implements Enumeration {
-	static final EmptyEnumeration EMPTY_ENUMERATION
-	    = new EmptyEnumeration();
+        static final EmptyEnumeration EMPTY_ENUMERATION
+            = new EmptyEnumeration();
 
-	public boolean hasMoreElements() { return false; }
-	public E nextElement() { throw new NoSuchElementException(); }
+        public boolean hasMoreElements() { return false; }
+        public E nextElement() { throw new NoSuchElementException(); }
     }
 
     /**
@@ -3070,22 +3110,22 @@ public class Collections {
      */
     @SuppressWarnings("unchecked")
     public static final  Set emptySet() {
-	return (Set) EMPTY_SET;
+        return (Set) EMPTY_SET;
     }
 
     /**
      * @serial include
      */
     private static class EmptySet
-	extends AbstractSet
-	implements Serializable
+        extends AbstractSet
+        implements Serializable
     {
-	private static final long serialVersionUID = 1582296315990362920L;
+        private static final long serialVersionUID = 1582296315990362920L;
 
-	public Iterator iterator() { return emptyIterator(); }
+        public Iterator iterator() { return emptyIterator(); }
 
         public int size() {return 0;}
-	public boolean isEmpty() {return true;}
+        public boolean isEmpty() {return true;}
 
         public boolean contains(Object obj) {return false;}
         public boolean containsAll(Collection c) { return c.isEmpty(); }
@@ -3098,7 +3138,7 @@ public class Collections {
             return a;
         }
 
-	// Preserves singleton property
+        // Preserves singleton property
         private Object readResolve() {
             return EMPTY_SET;
         }
@@ -3129,26 +3169,26 @@ public class Collections {
      */
     @SuppressWarnings("unchecked")
     public static final  List emptyList() {
-	return (List) EMPTY_LIST;
+        return (List) EMPTY_LIST;
     }
 
     /**
      * @serial include
      */
     private static class EmptyList
-	extends AbstractList
-	implements RandomAccess, Serializable {
-	private static final long serialVersionUID = 8842843931221139166L;
-
-	public Iterator iterator() {
-	    return emptyIterator();
-	}
-	public ListIterator listIterator() {
-	    return emptyListIterator();
-	}
+        extends AbstractList
+        implements RandomAccess, Serializable {
+        private static final long serialVersionUID = 8842843931221139166L;
 
-	public int size() {return 0;}
-	public boolean isEmpty() {return true;}
+        public Iterator iterator() {
+            return emptyIterator();
+        }
+        public ListIterator listIterator() {
+            return emptyListIterator();
+        }
+
+        public int size() {return 0;}
+        public boolean isEmpty() {return true;}
 
         public boolean contains(Object obj) {return false;}
         public boolean containsAll(Collection c) { return c.isEmpty(); }
@@ -3203,15 +3243,15 @@ public class Collections {
      */
     @SuppressWarnings("unchecked")
     public static final  Map emptyMap() {
-	return (Map) EMPTY_MAP;
+        return (Map) EMPTY_MAP;
     }
 
     /**
      * @serial include
      */
     private static class EmptyMap
-	extends AbstractMap
-	implements Serializable
+        extends AbstractMap
+        implements Serializable
     {
         private static final long serialVersionUID = 6428348081105594320L;
 
@@ -3219,7 +3259,7 @@ public class Collections {
         public boolean isEmpty()                   {return true;}
         public boolean containsKey(Object key)     {return false;}
         public boolean containsValue(Object value) {return false;}
-	public V get(Object key)                   {return null;}
+        public V get(Object key)                   {return null;}
         public Set keySet()                     {return emptySet();}
         public Collection values()              {return emptySet();}
         public Set> entrySet()      {return emptySet();}
@@ -3246,43 +3286,43 @@ public class Collections {
      * @return an immutable set containing only the specified object.
      */
     public static  Set singleton(T o) {
-	return new SingletonSet(o);
+        return new SingletonSet(o);
     }
 
     static  Iterator singletonIterator(final E e) {
-	return new Iterator() {
-	    private boolean hasNext = true;
-	    public boolean hasNext() {
-		return hasNext;
-	    }
-	    public E next() {
-		if (hasNext) {
-		    hasNext = false;
-		    return e;
-		}
-		throw new NoSuchElementException();
-	    }
-	    public void remove() {
-		throw new UnsupportedOperationException();
-	    }
-	};
+        return new Iterator() {
+            private boolean hasNext = true;
+            public boolean hasNext() {
+                return hasNext;
+            }
+            public E next() {
+                if (hasNext) {
+                    hasNext = false;
+                    return e;
+                }
+                throw new NoSuchElementException();
+            }
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+        };
     }
 
     /**
      * @serial include
      */
     private static class SingletonSet
-	extends AbstractSet
-	implements Serializable
+        extends AbstractSet
+        implements Serializable
     {
-	private static final long serialVersionUID = 3193687207550431679L;
+        private static final long serialVersionUID = 3193687207550431679L;
 
-        final private E element;
+        private final E element;
 
         SingletonSet(E e) {element = e;}
 
         public Iterator iterator() {
-	    return singletonIterator(element);
+            return singletonIterator(element);
         }
 
         public int size() {return 1;}
@@ -3299,15 +3339,15 @@ public class Collections {
      * @since 1.3
      */
     public static  List singletonList(T o) {
-	return new SingletonList(o);
+        return new SingletonList(o);
     }
 
     /**
      * @serial include
      */
     private static class SingletonList
-	extends AbstractList
-	implements RandomAccess, Serializable {
+        extends AbstractList
+        implements RandomAccess, Serializable {
 
         private static final long serialVersionUID = 3093736618740652951L;
 
@@ -3316,7 +3356,7 @@ public class Collections {
         SingletonList(E obj)                {element = obj;}
 
         public Iterator iterator() {
-	    return singletonIterator(element);
+            return singletonIterator(element);
         }
 
         public int size()                   {return 1;}
@@ -3341,19 +3381,19 @@ public class Collections {
      * @since 1.3
      */
     public static  Map singletonMap(K key, V value) {
-	return new SingletonMap(key, value);
+        return new SingletonMap(key, value);
     }
 
     /**
      * @serial include
      */
     private static class SingletonMap
-	  extends AbstractMap
-	  implements Serializable {
-	private static final long serialVersionUID = -6979724477215052911L;
+          extends AbstractMap
+          implements Serializable {
+        private static final long serialVersionUID = -6979724477215052911L;
 
         private final K k;
-	private final V v;
+        private final V v;
 
         SingletonMap(K key, V value) {
             k = key;
@@ -3374,24 +3414,24 @@ public class Collections {
         private transient Set> entrySet = null;
         private transient Collection values = null;
 
-	public Set keySet() {
-	    if (keySet==null)
-		keySet = singleton(k);
-	    return keySet;
-	}
-
-	public Set> entrySet() {
-	    if (entrySet==null)
-		entrySet = Collections.>singleton(
-		    new SimpleImmutableEntry(k, v));
-	    return entrySet;
-	}
-
-	public Collection values() {
-	    if (values==null)
-		values = singleton(v);
-	    return values;
-	}
+        public Set keySet() {
+            if (keySet==null)
+                keySet = singleton(k);
+            return keySet;
+        }
+
+        public Set> entrySet() {
+            if (entrySet==null)
+                entrySet = Collections.>singleton(
+                    new SimpleImmutableEntry(k, v));
+            return entrySet;
+        }
+
+        public Collection values() {
+            if (values==null)
+                values = singleton(v);
+            return values;
+        }
 
     }
 
@@ -3407,14 +3447,14 @@ public class Collections {
      * @param  n the number of elements in the returned list.
      * @param  o the element to appear repeatedly in the returned list.
      * @return an immutable list consisting of n copies of the
-     * 	       specified object.
-     * @throws IllegalArgumentException if n < 0.
+     *         specified object.
+     * @throws IllegalArgumentException if {@code n < 0}
      * @see    List#addAll(Collection)
      * @see    List#addAll(int, Collection)
      */
     public static  List nCopies(int n, T o) {
-	if (n < 0)
-	    throw new IllegalArgumentException("List length = " + n);
+        if (n < 0)
+            throw new IllegalArgumentException("List length = " + n);
         return new CopiesList(n, o);
     }
 
@@ -3422,8 +3462,8 @@ public class Collections {
      * @serial include
      */
     private static class CopiesList
-	extends AbstractList
-	implements RandomAccess, Serializable
+        extends AbstractList
+        implements RandomAccess, Serializable
     {
         private static final long serialVersionUID = 2739099268398711800L;
 
@@ -3431,7 +3471,7 @@ public class Collections {
         final E element;
 
         CopiesList(int n, E e) {
-	    assert n >= 0;
+            assert n >= 0;
             this.n = n;
             element = e;
         }
@@ -3444,13 +3484,13 @@ public class Collections {
             return n != 0 && eq(obj, element);
         }
 
-	public int indexOf(Object o) {
-	    return contains(o) ? 0 : -1;
-	}
-
-	public int lastIndexOf(Object o) {
-	    return contains(o) ? n - 1 : -1;
-	}
+        public int indexOf(Object o) {
+            return contains(o) ? 0 : -1;
+        }
+
+        public int lastIndexOf(Object o) {
+            return contains(o) ? n - 1 : -1;
+        }
 
         public E get(int index) {
             if (index < 0 || index >= n)
@@ -3459,38 +3499,38 @@ public class Collections {
             return element;
         }
 
-	public Object[] toArray() {
-	    final Object[] a = new Object[n];
-	    if (element != null)
-		Arrays.fill(a, 0, n, element);
-	    return a;
-	}
-
-	public  T[] toArray(T[] a) {
-	    final int n = this.n;
-	    if (a.length < n) {
-		a = (T[])java.lang.reflect.Array
-		    .newInstance(a.getClass().getComponentType(), n);
-		if (element != null)
-		    Arrays.fill(a, 0, n, element);
-	    } else {
-		Arrays.fill(a, 0, n, element);
-		if (a.length > n)
-		    a[n] = null;
-	    }
-	    return a;
-	}
-
-	public List subList(int fromIndex, int toIndex) {
-	    if (fromIndex < 0)
-		throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
-	    if (toIndex > n)
-		throw new IndexOutOfBoundsException("toIndex = " + toIndex);
-	    if (fromIndex > toIndex)
-		throw new IllegalArgumentException("fromIndex(" + fromIndex +
-						   ") > toIndex(" + toIndex + ")");
-	    return new CopiesList(toIndex - fromIndex, element);
-	}
+        public Object[] toArray() {
+            final Object[] a = new Object[n];
+            if (element != null)
+                Arrays.fill(a, 0, n, element);
+            return a;
+        }
+
+        public  T[] toArray(T[] a) {
+            final int n = this.n;
+            if (a.length < n) {
+                a = (T[])java.lang.reflect.Array
+                    .newInstance(a.getClass().getComponentType(), n);
+                if (element != null)
+                    Arrays.fill(a, 0, n, element);
+            } else {
+                Arrays.fill(a, 0, n, element);
+                if (a.length > n)
+                    a[n] = null;
+            }
+            return a;
+        }
+
+        public List subList(int fromIndex, int toIndex) {
+            if (fromIndex < 0)
+                throw new IndexOutOfBoundsException("fromIndex = " + fromIndex);
+            if (toIndex > n)
+                throw new IndexOutOfBoundsException("toIndex = " + toIndex);
+            if (fromIndex > toIndex)
+                throw new IllegalArgumentException("fromIndex(" + fromIndex +
+                                                   ") > toIndex(" + toIndex + ")");
+            return new CopiesList(toIndex - fromIndex, element);
+        }
     }
 
     /**
@@ -3502,14 +3542,14 @@ public class Collections {
      * objects that implement the Comparable interface in
      * reverse-natural-order.  For example, suppose a is an array of
      * strings. Then: 
-     * 		Arrays.sort(a, Collections.reverseOrder());
+     *          Arrays.sort(a, Collections.reverseOrder());
      * 
sorts the array in reverse-lexicographic (alphabetical) order.

* * The returned comparator is serializable. * * @return a comparator that imposes the reverse of the natural - * ordering on a collection of objects that implement - * the Comparable interface. + * ordering on a collection of objects that implement + * the Comparable interface. * @see Comparable */ public static Comparator reverseOrder() { @@ -3520,12 +3560,12 @@ public class Collections { * @serial include */ private static class ReverseComparator - implements Comparator>, Serializable { + implements Comparator>, Serializable { - private static final long serialVersionUID = 7207038068494060240L; + private static final long serialVersionUID = 7207038068494060240L; - static final ReverseComparator REVERSE_ORDER - = new ReverseComparator(); + static final ReverseComparator REVERSE_ORDER + = new ReverseComparator(); public int compare(Comparable c1, Comparable c2) { return c2.compareTo(c1); @@ -3552,8 +3592,8 @@ public class Collections { if (cmp == null) return reverseOrder(); - if (cmp instanceof ReverseComparator2) - return ((ReverseComparator2)cmp).cmp; + if (cmp instanceof ReverseComparator2) + return ((ReverseComparator2)cmp).cmp; return new ReverseComparator2(cmp); } @@ -3584,15 +3624,15 @@ public class Collections { return cmp.compare(t2, t1); } - public boolean equals(Object o) { - return (o == this) || - (o instanceof ReverseComparator2 && - cmp.equals(((ReverseComparator2)o).cmp)); - } - - public int hashCode() { - return cmp.hashCode() ^ Integer.MIN_VALUE; - } + public boolean equals(Object o) { + return (o == this) || + (o instanceof ReverseComparator2 && + cmp.equals(((ReverseComparator2)o).cmp)); + } + + public int hashCode() { + return cmp.hashCode() ^ Integer.MIN_VALUE; + } } /** @@ -3605,16 +3645,16 @@ public class Collections { * @see Enumeration */ public static Enumeration enumeration(final Collection c) { - return new Enumeration() { - private final Iterator i = c.iterator(); + return new Enumeration() { + private final Iterator i = c.iterator(); - public boolean hasMoreElements() { - return i.hasNext(); - } - - public T nextElement() { - return i.next(); - } + public boolean hasMoreElements() { + return i.hasNext(); + } + + public T nextElement() { + return i.next(); + } }; } @@ -3813,7 +3853,7 @@ public class Collections { public boolean containsAll(Collection c) {return s.containsAll(c);} public boolean removeAll(Collection c) {return s.removeAll(c);} public boolean retainAll(Collection c) {return s.retainAll(c);} - // addAll is the only inherited implementation + // addAll is the only inherited implementation private static final long serialVersionUID = 2454657854757543876L; @@ -3851,7 +3891,7 @@ public class Collections { */ static class AsLIFOQueue extends AbstractQueue implements Queue, Serializable { - private static final long serialVersionUID = 1802017725587941708L; + private static final long serialVersionUID = 1802017725587941708L; private final Deque q; AsLIFOQueue(Deque q) { this.q = q; } public boolean add(E e) { q.addFirst(e); return true; } @@ -3869,9 +3909,9 @@ public class Collections { public Object[] toArray() { return q.toArray(); } public T[] toArray(T[] a) { return q.toArray(a); } public String toString() { return q.toString(); } - public boolean containsAll(Collection c) {return q.containsAll(c);} - public boolean removeAll(Collection c) {return q.removeAll(c);} - public boolean retainAll(Collection c) {return q.retainAll(c);} - // We use inherited addAll; forwarding addAll would be wrong + public boolean containsAll(Collection c) {return q.containsAll(c);} + public boolean removeAll(Collection c) {return q.removeAll(c);} + public boolean retainAll(Collection c) {return q.retainAll(c);} + // We use inherited addAll; forwarding addAll would be wrong } }