X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=third-party%2Ftriemap%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Ftriemap%2FTrieMap.java;fp=third-party%2Ftriemap%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Ftriemap%2FTrieMap.java;h=b0261bf0e871679dfbb097df4c93f03f197b8edb;hb=24a850c1cbacd32e00c42d1714410ff11e1d7647;hp=a7a92ee1bc1687ac1a6209dcb8284f1908f76408;hpb=7c8354f088de156274e6df3218543594be793f4d;p=yangtools.git diff --git a/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TrieMap.java b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TrieMap.java index a7a92ee1bc..b0261bf0e8 100644 --- a/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TrieMap.java +++ b/third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TrieMap.java @@ -26,7 +26,7 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentMap; -/*** +/** * This is a port of Scala's TrieMap class from the Scala Collections library. This implementation does not support * null keys nor null values. * @@ -58,6 +58,7 @@ public abstract class TrieMap extends AbstractMap implements Concurr * Returns a snapshot of this TrieMap. This operation is lock-free and * linearizable. * + *

* The snapshot is lazily updated - the first time some branch in the * snapshot or this TrieMap are accessed, they are rewritten. This means * that the work of rebuilding both the snapshot and this TrieMap is @@ -70,6 +71,7 @@ public abstract class TrieMap extends AbstractMap implements Concurr * Returns a read-only snapshot of this TrieMap. This operation is lock-free * and linearizable. * + *

* The snapshot is lazily updated - the first time some branch of this * TrieMap are accessed, it is rewritten. The work of creating the snapshot * is thus distributed across subsequent updates and accesses on this @@ -77,6 +79,7 @@ public abstract class TrieMap extends AbstractMap implements Concurr * unlike when calling the `snapshot` method, but the obtained snapshot * cannot be modified. * + *

* This method is used by other methods such as `size` and `iterator`. */ public abstract ImmutableTrieMap immutableSnapshot(); @@ -153,22 +156,23 @@ public abstract class TrieMap extends AbstractMap implements Concurr /** * Return an iterator over a TrieMap. * + *

* If this is a read-only snapshot, it would return a read-only iterator. * + *

* If it is the original TrieMap or a non-readonly snapshot, it would return * an iterator that would allow for updates. * - * @return + * @return An iterator. */ abstract AbstractIterator iterator(); /* internal methods provided for subclasses */ /** - * Return an iterator over a TrieMap. - * This is a read-only iterator. + * Return an iterator over a TrieMap. This is a read-only iterator. * - * @return + * @return A read-only iterator. */ final ImmutableIterator immutableIterator() { return new ImmutableIterator<>(immutableSnapshot()); @@ -179,8 +183,8 @@ public abstract class TrieMap extends AbstractMap implements Concurr return opt.orElse(null); } - final int computeHash(final K k) { - return equiv.hash(k); + final int computeHash(final K key) { + return equiv.hash(key); } final Object writeReplace() throws ObjectStreamException { @@ -213,11 +217,11 @@ public abstract class TrieMap extends AbstractMap implements Concurr /* private implementation methods */ @SuppressWarnings("unchecked") - private V lookuphc(final K k, final int hc) { + private V lookuphc(final K key, final int hc) { Object res; do { // Keep looping as long as RESTART is being indicated - res = RDCSS_READ_ROOT().rec_lookup(k, hc, 0, null, this); + res = RDCSS_READ_ROOT().rec_lookup(key, hc, 0, null, this); } while (res == RESTART); return (V) res;