BUG-7464: Add MainNode.trySize() 41/50041/9
authorRobert Varga <rovarga@cisco.com>
Thu, 5 Jan 2017 02:33:02 +0000 (03:33 +0100)
committerRobert Varga <nite@hq.sk>
Tue, 10 Jan 2017 23:44:43 +0000 (23:44 +0000)
commit38732c9e9834ba76f7cd1bae3d2d5e50e54a0bad
tree860197a39ee65b11d81576c93754d5b324fcfc95
parent422344ce9059492bebc277edf22189cd3d4ec178
BUG-7464: Add MainNode.trySize()

Having the ability to estimate size will be useful for Spliterators,
add a method for reading the currently-cached value without actually
computing it.

Also rename cachedSize() to size() and make it enforce being called
with an immutable snapshot. For CNodes this allows us to get rid
of atomic access to the size field, as the order of updates and
visibility propagation of size does not matter -- all concurrent
computations will arrive at the same result. The worst that can
happen we spend more time computing computing the value.

Change-Id: I84e33d96c7aa6f97cb33e0d1c31178916541c693
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/CNode.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/FailedNode.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/INode.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/ImmutableTrieMap.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/LNode.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/MainNode.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TNode.java