All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.gwt.emul.java.util.concurrent.ConcurrentSkipListMap Maven / Gradle / Ivy

Go to download

Everything needed to run a comprehensive dev environment. Just type X_ and pick a service from autocomplete; new dev modules will be added as they are built. The only dev service not included in the uber jar is xapi-dev-maven, as it includes all runtime dependencies of maven, adding ~4 seconds to build time, and 6 megabytes to the final output jar size (without xapi-dev-maven, it's ~1MB).

The newest version!
package java.util.concurrent;

import java.util.*;
import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;

/**
 * Very basic emulation for SkipListMap; it's just a TreeMap, to implement
 * all of the {@link NavigableMap} functionality.
 * 
 * @param  key type
 * @param  value type
 */
public class ConcurrentSkipListMap  extends TreeMap implements Cloneable, Serializable, ConcurrentMap {

  /**
   * Ensures that RPC will consider type parameter K to be exposed. It will be
   * pruned by dead code elimination.
   */
  @SuppressWarnings("unused")
  private K exposeKey;

  /**
   * Ensures that RPC will consider type parameter V to be exposed. It will be
   * pruned by dead code elimination.
   */
  @SuppressWarnings("unused")
  private V exposeValue;

  public ConcurrentSkipListMap() {
    super();
  }
  
  public ConcurrentSkipListMap(Comparator comparator) {
    super(comparator);
  }

  /**
   * Constructs a new map containing the same mappings as the given map, sorted
   * according to the {@linkplain Comparable natural ordering} of the keys.
   * 
   * @param m the map whose mappings are to be placed in this map
   * @throws ClassCastException if the keys in m are not
   * {@link Comparable}, or are not mutually comparable
   * @throws NullPointerException if the specified map or any of its keys or
   * values are null
   */
  public ConcurrentSkipListMap(Map m) {
    super(m);
  }

  /**
   * Constructs a new map containing the same mappings and using the same
   * ordering as the specified sorted map.
   * 
   * @param m the sorted map whose mappings are to be placed in this map, and
   * whose comparator is to be used to sort this map
   * @throws NullPointerException if the specified sorted map or any of its keys
   * or values are null
   */
  public ConcurrentSkipListMap(SortedMap m) {
    super(m);
  }

  public Object clone() {
    return new ConcurrentSkipListMap(this);
  }
  

  /**
   * If the specified key is not already associated with a value, associate it
   * with the given value. Performs
   * 
   * 
   * if (!map.containsKey(key))
   *   return map.put(key, value);
   * else
   *   return map.get(key);
   * 
*/ public V putIfAbsent(K key, V value) { if (!containsKey(key)) return put(key, value); else return get(key); } /** * Removes the entry for a key only if currently mapped to a given value. * Performs * *
   * if (map.containsKey(key) && map.get(key).equals(value)) {
   *   map.remove(key);
   *   return true;
   * } else
   *   return false;
   * 
*/ public boolean remove(Object key, Object value) { if (containsKey(key) && get(key).equals(value)) { remove(key); return true; } else return false; } /** * Replaces the entry for a key only if currently mapped to a given value. * Performs * *
   * if (map.containsKey(key) && map.get(key).equals(oldValue)) {
   *   map.put(key, newValue);
   *   return true;
   * } else
   *   return false;
   * 
* * except that the action is performed atomically. */ public boolean replace(K key, V oldValue, V newValue) { if (containsKey(key) && get(key).equals(oldValue)) { put(key, newValue); return true; } else return false; } /** * Replaces the entry for a key only if currently mapped to some value. This * performs * *
   * if (map.containsKey(key)) {
   *   return map.put(key, value);
   * } else
   *   return null;
   * 
* * except that the action is performed atomically. */ public V replace(K key, V value) { if (containsKey(key)) { return put(key, value); } else return null; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy