minor bug, TreeMap.NavigableSubMap.entrySetView usage

charlie hunt charlie.hunt at sun.com
Thu May 29 05:27:18 UTC 2008


Looks like TreeMap.NavigableSubMap.entrySetView is initialized to null, 
but it is never updated when an "entry set view" is created by 
TreeMap.AscendingSubMap.entrySet() or by 
TreeMap.DescendingSubMap.entrySet().

I think those two methods were intended to be implemented as:

For AscendingSubMap:
        public Set<Map.Entry<K,V>> entrySet() {
            EntrySetView es = entrySetView;
            return (es != null) ? es : (entrySetView = new 
AscendingEntrySetView());
        }
For DescendingSubMap:
        public Set<Map.Entry<K,V>> entrySet() {
            EntrySetView es = entrySetView;
            return (es != null) ? es : (entrySetView = new 
DescendingEntrySetView());

A related question:
Is there a need to explicitly initialize; 
NavigableSubMap.descendingMapView, NavigableSubMap.entrySetView and 
NavigableSubMap.navigableKeySetView to null?  Aren't they going to be 
initialized to null by default without requiring an explicit load & 
store of null?

thanks,

charlie ...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: charlie.hunt.vcf
Type: text/x-vcard
Size: 156 bytes
Desc: not available
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20080529/ecd20791/charlie.hunt.vcf>


More information about the core-libs-dev mailing list