--- jsr166/src/main/java/util/TreeSet.java 2007/05/20 07:54:01 1.26 +++ jsr166/src/main/java/util/TreeSet.java 2008/05/18 23:47:56 1.27 @@ -81,12 +81,12 @@ package java.util; * * @author Josh Bloch * @version %I%, %G% - * @see Collection - * @see Set - * @see HashSet + * @see Collection + * @see Set + * @see HashSet * @see Comparable * @see Comparator - * @see TreeMap + * @see TreeMap * @since 1.2 */ @@ -122,7 +122,7 @@ public class TreeSet extends Abstract * {@code ClassCastException}. */ public TreeSet() { - this(new TreeMap()); + this(new TreeMap()); } /** @@ -139,7 +139,7 @@ public class TreeSet extends Abstract * ordering} of the elements will be used. */ public TreeSet(Comparator comparator) { - this(new TreeMap(comparator)); + this(new TreeMap(comparator)); } /** @@ -170,7 +170,7 @@ public class TreeSet extends Abstract */ public TreeSet(SortedSet s) { this(s.comparator()); - addAll(s); + addAll(s); } /** @@ -189,14 +189,14 @@ public class TreeSet extends Abstract * @since 1.6 */ public Iterator descendingIterator() { - return m.descendingKeySet().iterator(); + return m.descendingKeySet().iterator(); } /** * @since 1.6 */ public NavigableSet descendingSet() { - return new TreeSet(m.descendingMap()); + return new TreeSet(m.descendingMap()); } /** @@ -205,7 +205,7 @@ public class TreeSet extends Abstract * @return the number of elements in this set (its cardinality) */ public int size() { - return m.size(); + return m.size(); } /** @@ -214,7 +214,7 @@ public class TreeSet extends Abstract * @return {@code true} if this set contains no elements */ public boolean isEmpty() { - return m.isEmpty(); + return m.isEmpty(); } /** @@ -232,7 +232,7 @@ public class TreeSet extends Abstract * does not permit null elements */ public boolean contains(Object o) { - return m.containsKey(o); + return m.containsKey(o); } /** @@ -253,7 +253,7 @@ public class TreeSet extends Abstract * does not permit null elements */ public boolean add(E e) { - return m.put(e, PRESENT)==null; + return m.put(e, PRESENT)==null; } /** @@ -274,7 +274,7 @@ public class TreeSet extends Abstract * does not permit null elements */ public boolean remove(Object o) { - return m.remove(o)==PRESENT; + return m.remove(o)==PRESENT; } /** @@ -282,7 +282,7 @@ public class TreeSet extends Abstract * The set will be empty after this call returns. */ public void clear() { - m.clear(); + m.clear(); } /** @@ -299,7 +299,7 @@ public class TreeSet extends Abstract public boolean addAll(Collection c) { // Use linear-time version if applicable if (m.size()==0 && c.size() > 0 && - c instanceof SortedSet && + c instanceof SortedSet && m instanceof TreeMap) { SortedSet set = (SortedSet) c; TreeMap map = (TreeMap) m; @@ -323,7 +323,7 @@ public class TreeSet extends Abstract */ public NavigableSet subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) { - return new TreeSet(m.subMap(fromElement, fromInclusive, + return new TreeSet(m.subMap(fromElement, fromInclusive, toElement, toInclusive)); } @@ -336,7 +336,7 @@ public class TreeSet extends Abstract * @since 1.6 */ public NavigableSet headSet(E toElement, boolean inclusive) { - return new TreeSet(m.headMap(toElement, inclusive)); + return new TreeSet(m.headMap(toElement, inclusive)); } /** @@ -348,7 +348,7 @@ public class TreeSet extends Abstract * @since 1.6 */ public NavigableSet tailSet(E fromElement, boolean inclusive) { - return new TreeSet(m.tailMap(fromElement, inclusive)); + return new TreeSet(m.tailMap(fromElement, inclusive)); } /** @@ -359,7 +359,7 @@ public class TreeSet extends Abstract * @throws IllegalArgumentException {@inheritDoc} */ public SortedSet subSet(E fromElement, E toElement) { - return subSet(fromElement, true, toElement, false); + return subSet(fromElement, true, toElement, false); } /** @@ -370,7 +370,7 @@ public class TreeSet extends Abstract * @throws IllegalArgumentException {@inheritDoc} */ public SortedSet headSet(E toElement) { - return headSet(toElement, false); + return headSet(toElement, false); } /** @@ -381,7 +381,7 @@ public class TreeSet extends Abstract * @throws IllegalArgumentException {@inheritDoc} */ public SortedSet tailSet(E fromElement) { - return tailSet(fromElement, true); + return tailSet(fromElement, true); } public Comparator comparator() { @@ -472,11 +472,11 @@ public class TreeSet extends Abstract */ public Object clone() { TreeSet clone = null; - try { - clone = (TreeSet) super.clone(); - } catch (CloneNotSupportedException e) { - throw new InternalError(); - } + try { + clone = (TreeSet) super.clone(); + } catch (CloneNotSupportedException e) { + throw new InternalError(); + } clone.m = new TreeMap(m); return clone; @@ -496,8 +496,8 @@ public class TreeSet extends Abstract */ private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { - // Write out any hidden stuff - s.defaultWriteObject(); + // Write out any hidden stuff + s.defaultWriteObject(); // Write out Comparator s.writeObject(m.comparator()); @@ -505,8 +505,8 @@ public class TreeSet extends Abstract // Write out size s.writeInt(m.size()); - // Write out all elements in the proper order. - for (Iterator i=m.keySet().iterator(); i.hasNext(); ) + // Write out all elements in the proper order. + for (Iterator i=m.keySet().iterator(); i.hasNext(); ) s.writeObject(i.next()); } @@ -516,19 +516,19 @@ public class TreeSet extends Abstract */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { - // Read in any hidden stuff - s.defaultReadObject(); + // Read in any hidden stuff + s.defaultReadObject(); // Read in Comparator Comparator c = (Comparator) s.readObject(); // Create backing TreeMap - TreeMap tm; - if (c==null) - tm = new TreeMap(); - else - tm = new TreeMap(c); - m = tm; + TreeMap tm; + if (c==null) + tm = new TreeMap(); + else + tm = new TreeMap(c); + m = tm; // Read in size int size = s.readInt();