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.6 by dl, Wed Mar 23 11:20:27 2005 UTC vs.
Revision 1.7 by dl, Thu Mar 31 15:23:10 2005 UTC

# Line 1308 | Line 1308 | public class TreeMap<K,V>
1308          }
1309  
1310          public boolean isEmpty() {
1311 <            return entrySet.isEmpty();
1311 >            return entrySet().isEmpty();
1312          }
1313  
1314          public boolean containsKey(Object key) {
# Line 1372 | Line 1372 | public class TreeMap<K,V>
1372          public Map.Entry<K,V> pollFirstEntry() {
1373              TreeMap.Entry<K,V> e = fromStart ?
1374                  getFirstEntry() : getCeilingEntry(fromKey);
1375 <            if (e == null || (!fromStart && compare(e.key, fromKey) < 0))
1375 >            if (e == null || (!toEnd && compare(e.key, toKey) >= 0))
1376                  return null;
1377              Map.Entry result = new AbstractMap.SimpleImmutableEntry(e);
1378              deleteEntry(e);
# Line 1382 | Line 1382 | public class TreeMap<K,V>
1382          public Map.Entry<K,V> pollLastEntry() {
1383              TreeMap.Entry<K,V> e = toEnd ?
1384                  getLastEntry() : getLowerEntry(toKey);
1385 <            if (e == null || (!toEnd && compare(e.key, toKey) >= 0))
1385 >            if (e == null || (!fromStart && compare(e.key, fromKey) < 0))
1386                  return null;
1387              Map.Entry result = new AbstractMap.SimpleImmutableEntry(e);
1388              deleteEntry(e);
# Line 1462 | Line 1462 | public class TreeMap<K,V>
1462              return e == null? null : e.key;
1463          }
1464  
1465 <        private transient Set<Map.Entry<K,V>> entrySet = new EntrySetView();
1465 >        private transient Set<Map.Entry<K,V>> entrySet = null;
1466  
1467          public Set<Map.Entry<K,V>> entrySet() {
1468 <            return entrySet;
1468 >            Set<Map.Entry<K,V>> es = entrySet;
1469 >            return (es != null)? es : (entrySet = new EntrySetView());
1470          }
1471  
1472          private class EntrySetView extends AbstractSet<Map.Entry<K,V>> {
# Line 2162 | Line 2163 | public class TreeMap<K,V>
2163          // Write out size (number of Mappings)
2164          s.writeInt(size);
2165  
2166 +        Set<Map.Entry<K,V>> es = entrySet();
2167          // Write out keys and values (alternating)
2168 <        for (Iterator<Map.Entry<K,V>> i = entrySet().iterator(); i.hasNext(); ) {
2168 >        for (Iterator<Map.Entry<K,V>> i = es.iterator(); i.hasNext(); ) {
2169              Map.Entry<K,V> e = i.next();
2170              s.writeObject(e.getKey());
2171              s.writeObject(e.getValue());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines