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

Comparing jsr166/src/jsr166e/LongAdderTable.java (file contents):
Revision 1.5 by jsr166, Sat Sep 10 01:38:28 2011 UTC vs.
Revision 1.7 by dl, Sun Oct 2 22:01:06 2011 UTC

# Line 53 | Line 53 | public class LongAdderTable<K> implement
53       * @return the adder associated with the key
54       */
55      public LongAdder install(K key) {
56 <        LongAdder a = map.get(key);
57 <        if (a == null) {
58 <            LongAdder r = new LongAdder();
59 <            if ((a = map.putIfAbsent(key, r)) == null)
60 <                a = r;
61 <        }
62 <        return a;
56 >        return map.computeIfAbsent(key, createAdder);
57      }
58  
59      /**
# Line 71 | Line 65 | public class LongAdderTable<K> implement
65       * @param x the value to add
66       */
67      public void add(K key, long x) {
68 <        LongAdder a = map.get(key);
75 <        if (a == null)
76 <            a = map.computeIfAbsent(key, createAdder);
77 <        a.add(x);
68 >        map.computeIfAbsent(key, createAdder).add(x);
69      }
70  
71      /**
# Line 136 | Line 127 | public class LongAdderTable<K> implement
127      /**
128       * Returns the sum totalled across all keys.
129       *
130 <     * @return the sum totalled across all keys.
130 >     * @return the sum totalled across all keys
131       */
132      public long sumAll() {
133          long sum = 0L;
# Line 156 | Line 147 | public class LongAdderTable<K> implement
147      /**
148       * Totals, then resets, the sums associated with all keys.
149       *
150 <     * @return the sum totalled across all keys.
150 >     * @return the sum totalled across all keys
151       */
152      public long sumThenResetAll() {
153          long sum = 0L;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines