< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/LinkedMap.java

Print this page

        

*** 60,70 **** * A node of a linked list that is used as value in our map. The linked list uses insertion order * and allows fast iteration over its element even while the map is modified. */ static class Node { private final Object key; ! private final Object value; private volatile boolean alive = true; private volatile Node prev; private volatile Node next; --- 60,70 ---- * A node of a linked list that is used as value in our map. The linked list uses insertion order * and allows fast iteration over its element even while the map is modified. */ static class Node { private final Object key; ! private volatile Object value; private volatile boolean alive = true; private volatile Node prev; private volatile Node next;
*** 101,110 **** --- 101,118 ---- * @return the value */ public Object getValue() { return value; } + + /** + * Set the node's value + * @param value the new value + */ + void setValue(final Object value) { + this.value = value; + } } /** * An iterator over the elements in the map. */
*** 148,163 **** * Add a key-value pair to the map. * @param key the key * @param value the value */ public void set(final Object key, final Object value) { ! final Node newNode = new Node(key, value); ! final Node oldNode = data.put(key, newNode); ! if (oldNode != null) { ! unlink(oldNode); } - link(newNode); } /** * Get the value associated with {@code key}. * @param key the key --- 156,173 ---- * Add a key-value pair to the map. * @param key the key * @param value the value */ public void set(final Object key, final Object value) { ! Node node = data.get(key); ! if (node != null) { ! node.setValue(value); ! } else { ! node = new Node(key, value); ! data.put(key, node); ! link(node); } } /** * Get the value associated with {@code key}. * @param key the key
< prev index next >