RFR 8005704: Update ConcurrentHashMap to v8 (original) (raw)
Martin Buchholz martinrb at google.com
Tue May 28 20:03:01 UTC 2013
- Previous message: RFR 8005704: Update ConcurrentHashMap to v8
- Next message: RFR 8005704: Update ConcurrentHashMap to v8
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
A long-returning size method seems like a framework-level decision. We could add a default method to Collection.java and Map.java
default long mappingCount() { return size(); }
I'm not sure mappingCount is the best name, but all names will be confusing. Using the name "length()" at least has an onomatopoeic mnemonic advantage - it suggests that it might return a long.
/**
* Returns the number of mappings. This method should be used
* instead of {@link #size} because a ConcurrentHashMap may
* contain more mappings than can be represented as an int. The
* value returned is an estimate; the actual count may differ if
* there are concurrent insertions or removals.
*
* @return the number of mappings
*/
public long mappingCount() {
long n = sumCount();
return (n < 0L) ? 0L : n; // ignore transient negative values
}
- Previous message: RFR 8005704: Update ConcurrentHashMap to v8
- Next message: RFR 8005704: Update ConcurrentHashMap to v8
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]