--- jsr166/src/main/java/util/TreeMap.java 2005/03/31 15:23:10 1.7 +++ jsr166/src/main/java/util/TreeMap.java 2005/04/18 05:18:29 1.10 @@ -1,11 +1,11 @@ /* * %W% %E% * - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ -package java.util; +package java.util; /** @@ -559,7 +559,7 @@ public class TreeMap incrementSize(); root = new Entry(key, value, null); return null; - } + } while (true) { int cmp = compare(key, t.key); @@ -658,8 +658,8 @@ public class TreeMap /** * Returns a key-value mapping associated with the least * key in this map, or null if the map is empty. - * - * @return an Entry with least key, or null + * + * @return an Entry with least key, or null * if the map is empty. */ public Map.Entry firstEntry() { @@ -670,7 +670,7 @@ public class TreeMap /** * Returns a key-value mapping associated with the greatest * key in this map, or null if the map is empty. - * + * * @return an Entry with greatest key, or null * if the map is empty. */ @@ -682,13 +682,13 @@ public class TreeMap /** * Removes and returns a key-value mapping associated with * the least key in this map, or null if the map is empty. - * + * * @return the removed first entry of this map, or null * if the map is empty. */ public Map.Entry pollFirstEntry() { Entry p = getFirstEntry(); - if (p == null) + if (p == null) return null; Map.Entry result = new AbstractMap.SimpleImmutableEntry(p); deleteEntry(p); @@ -698,13 +698,13 @@ public class TreeMap /** * Removes and returns a key-value mapping associated with * the greatest key in this map, or null if the map is empty. - * + * * @return the removed last entry of this map, or null * if the map is empty. */ public Map.Entry pollLastEntry() { Entry p = getLastEntry(); - if (p == null) + if (p == null) return null; Map.Entry result = new AbstractMap.SimpleImmutableEntry(p); deleteEntry(p); @@ -714,8 +714,8 @@ public class TreeMap /** * Returns a key-value mapping associated with the least key * greater than or equal to the given key, or null if - * there is no such entry. - * + * there is no such entry. + * * @param key the key. * @return an Entry associated with ceiling of given key, or * null if there is no such Entry. @@ -734,7 +734,7 @@ public class TreeMap /** * Returns least key greater than or equal to the given key, or * null if there is no such key. - * + * * @param key the key. * @return the ceiling key, or null * if there is no such key. @@ -754,8 +754,8 @@ public class TreeMap /** * Returns a key-value mapping associated with the greatest key * less than or equal to the given key, or null if there - * is no such entry. - * + * is no such entry. + * * @param key the key. * @return an Entry associated with floor of given key, or null * if there is no such Entry. @@ -774,7 +774,7 @@ public class TreeMap * Returns the greatest key * less than or equal to the given key, or null if there * is no such key. - * + * * @param key the key. * @return the floor of given key, or null if there is no * such key. @@ -792,8 +792,8 @@ public class TreeMap /** * Returns a key-value mapping associated with the least key * strictly greater than the given key, or null if there - * is no such entry. - * + * is no such entry. + * * @param key the key. * @return an Entry with least key greater than the given key, or * null if there is no such Entry. @@ -811,7 +811,7 @@ public class TreeMap /** * Returns the least key strictly greater than the given key, or * null if there is no such key. - * + * * @param key the key. * @return the least key greater than the given key, or * null if there is no such key. @@ -829,8 +829,8 @@ public class TreeMap /** * Returns a key-value mapping associated with the greatest * key strictly less than the given key, or null if there is no - * such entry. - * + * such entry. + * * @param key the key. * @return an Entry with greatest key less than the given * key, or null if there is no such Entry. @@ -848,7 +848,7 @@ public class TreeMap /** * Returns the greatest key strictly less than the given key, or * null if there is no such key. - * + * * @param key the key. * @return the greatest key less than the given * key, or null if there is no such key. @@ -872,10 +872,7 @@ public class TreeMap */ private transient Set> entrySet = null; private transient Set> descendingEntrySet = null; - private transient Set descendingKeySet = null; - - transient Set keySet = null; // XXX remove when integrated - transient Collection values = null; // XXX remove when integrated + private transient Set descendingKeySet = null; /** * Returns a Set view of the keys contained in this map. The set's @@ -898,21 +895,21 @@ public class TreeMap public Iterator iterator() { return new KeyIterator(getFirstEntry()); } - + public int size() { return TreeMap.this.size(); } - + public boolean contains(Object o) { return containsKey(o); } - + public boolean remove(Object o) { int oldSize = size; TreeMap.this.remove(o); return size != oldSize; } - + public void clear() { TreeMap.this.clear(); } @@ -940,18 +937,18 @@ public class TreeMap public Iterator iterator() { return new ValueIterator(getFirstEntry()); } - + public int size() { return TreeMap.this.size(); } - + public boolean contains(Object o) { for (Entry e = getFirstEntry(); e != null; e = successor(e)) if (valEquals(e.getValue(), o)) return true; return false; } - + public boolean remove(Object o) { for (Entry e = getFirstEntry(); e != null; e = successor(e)) { if (valEquals(e.getValue(), o)) { @@ -961,7 +958,7 @@ public class TreeMap } return false; } - + public void clear() { TreeMap.this.clear(); } @@ -990,7 +987,7 @@ public class TreeMap public Iterator> iterator() { return new EntryIterator(getFirstEntry()); } - + public boolean contains(Object o) { if (!(o instanceof Map.Entry)) return false; @@ -999,7 +996,7 @@ public class TreeMap Entry p = getEntry(entry.getKey()); return p != null && valEquals(p.getValue(), value); } - + public boolean remove(Object o) { if (!(o instanceof Map.Entry)) return false; @@ -1012,11 +1009,11 @@ public class TreeMap } return false; } - + public int size() { return TreeMap.this.size(); } - + public void clear() { TreeMap.this.clear(); } @@ -1034,7 +1031,7 @@ public class TreeMap * operations. It does not support the add or * addAll operations. * - * @return a set view of the mappings contained in this map, in + * @return a set view of the mappings contained in this map, in * descending key order * @see Map.Entry */ @@ -1354,7 +1351,7 @@ public class TreeMap } public Map.Entry firstEntry() { - TreeMap.Entry e = fromStart ? + TreeMap.Entry e = fromStart ? getFirstEntry() : getCeilingEntry(fromKey); if (e == null || (!toEnd && compare(e.key, toKey) >= 0)) return null; @@ -1362,7 +1359,7 @@ public class TreeMap } public Map.Entry lastEntry() { - TreeMap.Entry e = toEnd ? + TreeMap.Entry e = toEnd ? getLastEntry() : getLowerEntry(toKey); if (e == null || (!fromStart && compare(e.key, fromKey) < 0)) return null; @@ -1370,7 +1367,7 @@ public class TreeMap } public Map.Entry pollFirstEntry() { - TreeMap.Entry e = fromStart ? + TreeMap.Entry e = fromStart ? getFirstEntry() : getCeilingEntry(fromKey); if (e == null || (!toEnd && compare(e.key, toKey) >= 0)) return null; @@ -1380,7 +1377,7 @@ public class TreeMap } public Map.Entry pollLastEntry() { - TreeMap.Entry e = toEnd ? + TreeMap.Entry e = toEnd ? getLastEntry() : getLowerEntry(toKey); if (e == null || (!fromStart && compare(e.key, fromKey) < 0)) return null; @@ -1523,7 +1520,7 @@ public class TreeMap } private transient Set> descendingEntrySetView = null; - private transient Set descendingKeySetView = null; + private transient Set descendingKeySetView = null; public Set> descendingEntrySet() { Set> es = descendingEntrySetView; @@ -1547,17 +1544,17 @@ public class TreeMap public Iterator iterator() { return new Iterator() { private Iterator> i = descendingEntrySet().iterator(); - + public boolean hasNext() { return i.hasNext(); } public K next() { return i.next().getKey(); } public void remove() { i.remove(); } }; } - + public int size() { return SubMap.this.size(); } - + public boolean contains(Object k) { return SubMap.this.containsKey(k); }