Hi Tomasz, If there was any rejection it was probably due to time constraints than for any technical reasons.
It should be easy to refactor the TreeMap.put implementation into say a private putVal accepting a boolean argument and both put and putIfAbsent call putVal (same pattern as in HashMap). The compute* methods may require separate implementations with almost duplicated kind of patterns. An OCA [1] compliant patch would be appreciated, which should also include updates to relevant tests where appropriate. Thanks, Paul. [1] http://www.oracle.com/technetwork/community/oca-486395.html <http://www.oracle.com/technetwork/community/oca-486395.html> > On 20 May 2016, at 15:19, Tomasz Kowalczewski <[email protected]> > wrote: > > Hi all, > > TreeMap does not have its own specific overrides of Map methods that were > added in java 8. In our specific usage we do what is effective a merge > operation: > > For incoming K and V: > 1. get value from map > 2. if present - merge with incoming value V > 3. if absent - associate K with V in the map > > For case where K is not in the map we traverse the tree map it twice. > Implementing TreeMap specific override of putIfAbsent would allow as to > avoid this cost. > > Was such change considered in past and rejected? Is anyone interested in a > patch that implements it? > > -- > Regards, > Tomasz Kowalczewski
