Removes all mappings from this map whose values are zero. This method is not atomic: the map may be visible in intermediate states, where some of the zero values have been removed and others have not.
()
| 280 | |
| 281 | |
| 282 | public void removeAllZeros() { |
| 283 | Iterator<Map.Entry<K, AtomicLong>> entryIterator = map.entrySet().iterator(); |
| 284 | while (entryIterator.hasNext()) { |
| 285 | Map.Entry<K, AtomicLong> entry = entryIterator.next(); |
| 286 | AtomicLong atomic = entry.getValue(); |
| 287 | if (atomic != null && atomic.get() == 0L) { |
| 288 | entryIterator.remove(); |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * Returns the sum of all values in this map. |