java.util.AbstractMap类的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中java.util.AbstractMap类的一些代码示例,展示了AbstractMap类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractMap类的具体详情如下:
包路径:java.util.AbstractMap
类名称:AbstractMap

AbstractMap介绍

[英]A base class for Map implementations.

Subclasses that permit new mappings to be added must override #put.

The default implementations of many methods are inefficient for large maps. For example in the default implementation, each call to #getperforms a linear iteration of the entry set. Subclasses should override such methods to improve their performance.
[中]映射实现的基类。
允许添加新映射的子类必须覆盖#put。
对于大型映射,许多方法的默认实现效率低下。例如,在默认实现中,对#Get的每次调用都会对条目集执行线性迭代。子类应该重写这些方法以提高其性能。

代码示例

代码示例来源:origin: robovm/robovm

@Override public Object clone() {
  try {
    @SuppressWarnings("unchecked") // super.clone() must return the same type
    TreeMap<K, V> map = (TreeMap<K, V>) super.clone();
    map.root = root != null ? root.copy(null) : null;
    map.entrySet = null;
    map.keySet = null;
    return map;
  } catch (CloneNotSupportedException e) {
    throw new AssertionError();
  }
}

代码示例来源:origin: commons-collections/commons-collections

/**
 * Returns true if the bean defines a property whose current value is
 * the given object.
 *
 * @param value  the value to check
 * @return false  true if the bean has at least one property whose 
 *   current value is that object, false otherwise
 */
public boolean containsValue(Object value) {
  // use default implementation
  return super.containsValue(value);
}

代码示例来源:origin: apache/geode

@Override
public boolean equals(final Object o) {
 if (this == o) {
  return true;
 }
 if (o == null || getClass() != o.getClass()) {
  return false;
 }
 if (!super.equals(o)) {
  return false;
 }
 final BucketTargetingMap<?, ?> that = (BucketTargetingMap<?, ?>) o;
 if (!region.getFullPath().equals(that.region.getFullPath())) {
  return false;
 }
 return callbackArg.equals(that.callbackArg);
}

代码示例来源:origin: stackoverflow.com

public static void main(String args[]) {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("2", "whatever2");
map.put("1", "whatever1");
TreeMap<String, Object> map2 = new TreeMap<String, Object>();
map2.put("2", "whatever2");
map2.put("1", "whatever1");

System.out.println("Are maps equal (using equals):" + map.equals(map2));
System.out.println("Are maps equal (using toString().equals()):"
    + map.toString().equals(map2.toString()));

System.out.println("Map1:"+map.toString());
System.out.println("Map2:"+map2.toString());
}

代码示例来源:origin: org.apache.lucene/lucene-core

final Set<Object> originalKeySet() {
 return super.keySet();
}

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs

@Override
void visitEnclosingElement(ImageElement element, ImageElement key,
  String value) throws IOException {
 // Special case as numBlocks is an attribute of the blocks element
 if(key == ImageElement.NUM_BLOCKS 
   && elements.containsKey(ImageElement.NUM_BLOCKS))
  elements.put(key, value);
 
 elemQ.push(element);
}

代码示例来源:origin: jenkinsci/jenkins

@Override
public R get(Object key) {
  if (key instanceof Integer) {
    int n = (Integer) key;
    return get(n);
  }
  return super.get(key);
}

代码示例来源:origin: edu.illinois.cs.cogcomp/LBJava

/**
 * Replaces all unquantified variables with the unique copy stored as a value of the given map;
 * also instantiates all quantified variables and stores them in the given map.
 *
 * @param m The map in which to find unique copies of the variables.
 **/
public void consolidateVariables(java.util.AbstractMap m) {
  variableMap = m;
  if (m.containsKey(left))
    left = (FirstOrderVariable) m.get(left);
  else
    m.put(left, left);
}

代码示例来源:origin: ConsenSys/eventeum

/**
 * {@inheritDoc}
 */
@Override
public void updateLatestBlock(String eventSpecHash, BigInteger blockNumber) {
  final BigInteger currentLatest = latestBlocks.get(eventSpecHash);
  if (currentLatest == null || blockNumber.compareTo(currentLatest) > 0) {
    latestBlocks.put(eventSpecHash, blockNumber);
  }
}

代码示例来源:origin: robovm/robovm

/**
 * {@inheritDoc}
 *
 * <p>This implementation iterates through {@code map}'s entry set, calling
 * {@code put()} for each.
 */
public void putAll(Map<? extends K, ? extends V> map) {
  for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
    put(entry.getKey(), entry.getValue());
  }
}

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs

/**
 * Reset the values of the elements we're tracking in order to handle
 * the next file
 */
private void reset() {
 elements.clear();
 for(ImageElement e : elementsToTrack) 
  elements.put(e, null);
 
 fileSize = 0l;
}

代码示例来源:origin: gov.sandia.foundry/gov-sandia-cognition-common-core

@Override
public Set<Integer> keySet()
{
  return super.keySet();
}

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs

@Override
void visit(ImageElement element, String value) throws IOException {
 // Explicitly label the root path
 if(element == ImageElement.INODE_PATH && value.equals(""))
  value = "/";
 
 // Special case of file size, which is sum of the num bytes in each block
 if(element == ImageElement.NUM_BYTES)
  fileSize += Long.parseLong(value);
 
 if(elements.containsKey(element) && element != ImageElement.NUM_BYTES)
  elements.put(element, value);
 
}

代码示例来源:origin: peter-lawrey/Java-Chronicle

@Override
public String get(Object key) {
  for (String s : scopeArray) {
    String key2 = s + key;
    Object obj = properties.get(key2);
    if (obj == null)
      continue;
    return String.valueOf(obj);
  }
  return super.get(String.valueOf(key));
}

代码示例来源:origin: it.unibo.alice.tuprolog/tuprolog

@Override //Alberto 
public Term copyAndRetainFreeVar(AbstractMap<Var,Var> vMap, int idExecCtx) {
  Term tt = getTerm();
  if (tt == this) {
    Var v = (vMap.get(this));
    if (v == null) {
      //No occurence of v before
      v = this; //!!!
      vMap.put(this,v);
    }
    return v;
  } else {
    return tt.copy(vMap, idExecCtx);
  }
}

代码示例来源:origin: MobiVM/robovm

/**
 * {@inheritDoc}
 *
 * <p>This implementation iterates through {@code map}'s entry set, calling
 * {@code put()} for each.
 */
public void putAll(Map<? extends K, ? extends V> map) {
  for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
    put(entry.getKey(), entry.getValue());
  }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs

/**
 * Reset the values of the elements we're tracking in order to handle
 * the next file
 */
private void reset() {
 elements.clear();
 for(ImageElement e : elementsToTrack) 
  elements.put(e, null);
 
 fileSize = 0l;
}

代码示例来源:origin: redisson/redisson

/**
 * Returns a shallow copy of this <code>IntHashMap</code> instance: the keys and
 * values themselves are not cloned.
 *
 * @return a shallow copy of this map.
 */
@Override
public IntHashMap clone() {
  try {
    IntHashMap t = (IntHashMap) super.clone();
    t.table = new Entry[table.length];
    for (int i = table.length; i-- > 0; ) {
      t.table[i] = (table[i] != null)
          ? (Entry) table[i].clone() : null;
    }
    t.keySet = null;
    t.entrySet = null;
    t.values = null;
    t.modCount = 0;
    return t;
  } catch (CloneNotSupportedException e) {
    // this shouldn't happen, since we are Cloneable
    throw new InternalError();
  }
}

代码示例来源:origin: wildfly/wildfly

/**
 * Returns true if the bean defines a property whose current value is
 * the given object.
 *
 * @param value  the value to check
 * @return false  true if the bean has at least one property whose 
 *   current value is that object, false otherwise
 */
public boolean containsValue(Object value) {
  // use default implementation
  return super.containsValue(value);
}

代码示例来源:origin: robovm/robovm

/**
 * Compares the argument to the receiver, and returns {@code true} if the
 * specified {@code Object} is an {@code EnumMap} and both {@code EnumMap}s contain the same mappings.
 *
 * @param object
 *            the {@code Object} to compare with this {@code EnumMap}.
 * @return boolean {@code true} if {@code object} is the same as this {@code EnumMap},
 *         {@code false} otherwise.
 * @see #hashCode()
 * @see #entrySet()
 */
@SuppressWarnings("unchecked")
@Override
public boolean equals(Object object) {
  if (this == object) {
    return true;
  }
  if (!(object instanceof EnumMap)) {
    return super.equals(object);
  }
  EnumMap<K, V> enumMap = (EnumMap<K, V>) object;
  if (keyType != enumMap.keyType || size() != enumMap.size()) {
    return false;
  }
  return Arrays.equals(hasMapping, enumMap.hasMapping)
      && Arrays.equals(values, enumMap.values);
}

相关文章