示例#1
0
 /** Remove all entries. */
 public void clear() {
   beforeWrite();
   try {
     root.removeAllRecursive();
     newRoot(Page.createEmpty(this, store.getCurrentVersion()));
   } finally {
     afterWrite();
   }
 }
示例#2
0
 /**
  * Remove a key-value pair, if the key exists.
  *
  * @param key the key (may not be null)
  * @return the old value if the key existed, or null otherwise
  */
 public V remove(Object key) {
   beforeWrite();
   try {
     long writeVersion = store.getCurrentVersion();
     Page p = copyOnWrite(root, writeVersion);
     @SuppressWarnings("unchecked")
     V result = (V) remove(p, writeVersion, key);
     newRoot(p);
     return result;
   } finally {
     afterWrite();
   }
 }
示例#3
0
 /**
  * Add or replace a key-value pair.
  *
  * @param key the key (may not be null)
  * @param value the value (may not be null)
  * @return the old value if the key existed, or null otherwise
  */
 @SuppressWarnings("unchecked")
 public V put(K key, V value) {
   DataUtils.checkArgument(value != null, "The value may not be null");
   beforeWrite();
   try {
     long writeVersion = store.getCurrentVersion();
     Page p = copyOnWrite(root, writeVersion);
     p = splitRootIfNeeded(p, writeVersion);
     Object result = put(p, writeVersion, key, value);
     newRoot(p);
     return (V) result;
   } finally {
     afterWrite();
   }
 }