ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/TreeMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/TreeMap.java (file contents):
Revision 1.37 by dl, Tue May 9 18:17:08 2006 UTC vs.
Revision 1.43 by jsr166, Sun May 20 07:54:01 2007 UTC

# Line 1 | Line 1
1   /*
2 < * %W% %E%
2 > * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
3 > * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4   *
5 < * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
6 < * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
5 > * This code is free software; you can redistribute it and/or modify it
6 > * under the terms of the GNU General Public License version 2 only, as
7 > * published by the Free Software Foundation.  Sun designates this
8 > * particular file as subject to the "Classpath" exception as provided
9 > * by Sun in the LICENSE file that accompanied this code.
10 > *
11 > * This code is distributed in the hope that it will be useful, but WITHOUT
12 > * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 > * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 > * version 2 for more details (a copy is included in the LICENSE file that
15 > * accompanied this code).
16 > *
17 > * You should have received a copy of the GNU General Public License version
18 > * 2 along with this work; if not, write to the Free Software Foundation,
19 > * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 > *
21 > * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 > * CA 95054 USA or visit www.sun.com if you need additional information or
23 > * have any questions.
24   */
25  
26   package java.util;
# Line 1121 | Line 1139 | public class TreeMap<K,V>
1139              if (lastReturned.left != null && lastReturned.right != null)
1140                  next = lastReturned;
1141              deleteEntry(lastReturned);
1142 <            expectedModCount++;
1142 >            expectedModCount = modCount;
1143              lastReturned = null;
1144          }
1145      }
# Line 1209 | Line 1227 | public class TreeMap<K,V>
1227      // SubMaps
1228  
1229      /**
1230 +     * Dummy value serving as unmatchable fence key for unbounded
1231 +     * SubMapIterators
1232 +     */
1233 +    private static final Object UNBOUNDED = new Object();
1234 +
1235 +    /**
1236       * @serial include
1237       */
1238      static abstract class NavigableSubMap<K,V> extends AbstractMap<K,V>
# Line 1547 | Line 1571 | public class TreeMap<K,V>
1571          abstract class SubMapIterator<T> implements Iterator<T> {
1572              TreeMap.Entry<K,V> lastReturned;
1573              TreeMap.Entry<K,V> next;
1574 <            final K fenceKey;
1574 >            final Object fenceKey;
1575              int expectedModCount;
1576  
1577              SubMapIterator(TreeMap.Entry<K,V> first,
# Line 1555 | Line 1579 | public class TreeMap<K,V>
1579                  expectedModCount = m.modCount;
1580                  lastReturned = null;
1581                  next = first;
1582 <                fenceKey = fence == null ? null : fence.key;
1582 >                fenceKey = fence == null ? UNBOUNDED : fence.key;
1583              }
1584  
1585              public final boolean hasNext() {
# Line 1689 | Line 1713 | public class TreeMap<K,V>
1713          }
1714  
1715          public NavigableMap<K,V> headMap(K toKey, boolean inclusive) {
1716 <            if (!inClosedRange(toKey))
1716 >            if (!inRange(toKey, inclusive))
1717                  throw new IllegalArgumentException("toKey out of range");
1718              return new AscendingSubMap(m,
1719                                         fromStart, lo,    loInclusive,
# Line 2353 | Line 2377 | public class TreeMap<K,V>
2377  
2378          if (hi < lo) return null;
2379  
2380 <        int mid = (lo + hi) / 2;
2380 >        int mid = (lo + hi) >>> 1;
2381  
2382          Entry<K,V> left  = null;
2383          if (lo < mid)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines