@Override public VectorClock clone() { return (VectorClock) super.clone(); }
/** * Copy all of the mappings from the specified map to this one, replacing * any mappings with the same keys. * * @param in the map whose mappings are to be copied */ public void putAll(Map in) { if (fast) { synchronized (this) { TreeMap temp = (TreeMap) map.clone(); temp.putAll(in); map = temp; } } else { synchronized (map) { map.putAll(in); } } }
/** * Remove any mapping for this key, and return any previously * mapped value. * * @param key the key whose mapping is to be removed * @return the value removed, or null */ public Object remove(Object key) { if (fast) { synchronized (this) { TreeMap temp = (TreeMap) map.clone(); Object result = temp.remove(key); map = temp; return (result); } } else { synchronized (map) { return (map.remove(key)); } } }
protected Map copyMap(Map map) { if (map instanceof HashMap) { return (Map) ((HashMap) map).clone(); } if (map instanceof SortedMap) { if (map instanceof TreeMap) { return (Map) ((TreeMap) map).clone(); } else { return new TreeMap((SortedMap) map); } } return new HashMap(map); }
/** * Associate the specified value with the specified key in this map. * If the map previously contained a mapping for this key, the old * value is replaced and returned. * * @param key the key with which the value is to be associated * @param value the value to be associated with this key * @return the value previously mapped to the key, or null */ public Object put(Object key, Object value) { if (fast) { synchronized (this) { TreeMap temp = (TreeMap) map.clone(); Object result = temp.put(key, value); map = temp; return (result); } } else { synchronized (map) { return (map.put(key, value)); } } }
/** * Copy all of the mappings from the specified map to this one, replacing * any mappings with the same keys. * * @param in the map whose mappings are to be copied */ public void putAll(Map in) { if (fast) { synchronized (this) { TreeMap temp = (TreeMap) map.clone(); temp.putAll(in); map = temp; } } else { synchronized (map) { map.putAll(in); } } }
/** * Remove any mapping for this key, and return any previously * mapped value. * * @param key the key whose mapping is to be removed * @return the value removed, or null */ public Object remove(Object key) { if (fast) { synchronized (this) { TreeMap temp = (TreeMap) map.clone(); Object result = temp.remove(key); map = temp; return (result); } } else { synchronized (map) { return (map.remove(key)); } } }
/** * Associate the specified value with the specified key in this map. * If the map previously contained a mapping for this key, the old * value is replaced and returned. * * @param key the key with which the value is to be associated * @param value the value to be associated with this key * @return the value previously mapped to the key, or null */ public Object put(Object key, Object value) { if (fast) { synchronized (this) { TreeMap temp = (TreeMap) map.clone(); Object result = temp.put(key, value); map = temp; return (result); } } else { synchronized (map) { return (map.put(key, value)); } } }
/** * Returns a new {@code TreeSet} with the same elements, size and comparator * as this {@code TreeSet}. * * @return a shallow copy of this {@code TreeSet}. * @see java.lang.Cloneable */ @SuppressWarnings("unchecked") @Override public Object clone() { try { TreeSet<E> clone = (TreeSet<E>) super.clone(); if (backingMap instanceof TreeMap) { clone.backingMap = (NavigableMap<E, Object>) ((TreeMap<E, Object>) backingMap) .clone(); } else { clone.backingMap = new TreeMap<E, Object>(backingMap); } return clone; } catch (CloneNotSupportedException e) { throw new AssertionError(e); } }
public boolean retainAll(Collection o) { if (fast) { synchronized (FastTreeMap.this) { TreeMap temp = (TreeMap) map.clone(); boolean r = get(temp).retainAll(o); map = temp; return r; } } else { synchronized (map) { return get(map).retainAll(o); } } }
public boolean remove(Object o) { if (fast) { synchronized (FastTreeMap.this) { TreeMap temp = (TreeMap) map.clone(); boolean r = get(temp).remove(o); map = temp; return r; } } else { synchronized (map) { return get(map).remove(o); } } }
public boolean removeAll(Collection o) { if (fast) { synchronized (FastTreeMap.this) { TreeMap temp = (TreeMap) map.clone(); boolean r = get(temp).removeAll(o); map = temp; return r; } } else { synchronized (map) { return get(map).removeAll(o); } } }
public boolean removeAll(Collection o) { if (fast) { synchronized (FastTreeMap.this) { TreeMap temp = (TreeMap) map.clone(); boolean r = get(temp).removeAll(o); map = temp; return r; } } else { synchronized (map) { return get(map).removeAll(o); } } }
public boolean retainAll(Collection o) { if (fast) { synchronized (FastTreeMap.this) { TreeMap temp = (TreeMap) map.clone(); boolean r = get(temp).retainAll(o); map = temp; return r; } } else { synchronized (map) { return get(map).retainAll(o); } } }
public boolean remove(Object o) { if (fast) { synchronized (FastTreeMap.this) { TreeMap temp = (TreeMap) map.clone(); boolean r = get(temp).remove(o); map = temp; return r; } } else { synchronized (map) { return get(map).remove(o); } } }
public Object clone() throws CloneNotSupportedException { Node n=new Node(name, fqn, parent != null? (Node)parent.clone() : null, data); if(children != null) n.children=(TreeMap)children.clone(); return n; }
/** * Attempts to use native {@link Object#clone()} methods on available map * types. If a map cannot be properly cloned, a new {@link HashMap} is * returned. * * @param map The map input * @param <K> The key type * @param <V> The value type * @return A copied map */ @SuppressWarnings("unchecked") public static <K, V> Map<K, V> copyMap(Map<? extends K, ? extends V> map) { try { if (map instanceof HashMap) { return (Map<K, V>) ((HashMap<? extends K, ? extends V>) map).clone(); } else if (map instanceof IdentityHashMap) { return (Map<K, V>) ((IdentityHashMap<?, ?>) map).clone(); } else if (map instanceof EnumMap) { return (Map<K, V>) ((EnumMap<?, V>) map).clone(); } else if (map instanceof TreeMap) { return (Map<K, V>) ((TreeMap<K, V>) map).clone(); } else if (map instanceof ConcurrentHashMap) { return (Map<K, V>) new ConcurrentHashMap<>(map); } } catch (Exception ignored) { } return new HashMap<>(map); }
/** * Returns a shallow copy of this <tt>HashMap</tt> instance: the keys and * values themselves are not cloned. * * @return a shallow copy of this map */ @Override public IgnoreLanguagesSettings clone() { IgnoreLanguagesSettings copy = (IgnoreLanguagesSettings) super.clone(); for (Map.Entry<IgnoreLanguage, TreeMap<IgnoreLanguagesSettings.KEY, Object>> entry : copy.entrySet()) { @SuppressWarnings("unchecked") TreeMap<IgnoreLanguagesSettings.KEY, Object> data = (TreeMap<KEY, Object>) entry.getValue().clone(); copy.put(entry.getKey(), data); } return copy; } }
TreeMap tempPrincipalPermissions = (TreeMap) base.principalPermissions.clone(); int tempGlobalPermissions = base.globalPermissions;
/** * Constructor with options to be copied. * @param opts options */ @SuppressWarnings("unchecked") protected Options(final Options opts) { options = (TreeMap<String, Option<?>>) opts.options.clone(); values = (TreeMap<String, Object>) opts.values.clone(); free = (HashMap<String, String>) opts.free.clone(); user.add(opts.user); file = opts.file; }