java.util.Hashtable.remove()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(214)

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

Hashtable.remove介绍

[英]Removes the key/value pair with the specified key from this Hashtable.
[中]从此哈希表中删除具有指定键的键/值对。

代码示例

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

/**
 * Set this required element found.
 *
 */
void setRequiredFound(String elem, boolean found)
{
 if (m_requiredFound.get(elem) != null) 
    m_requiredFound.remove(elem);
}

代码示例来源:origin: Sable/soot

public void removeEdge(Object from, Object to) {
 Hashtable targets = sources.get(from);
 if (targets == null) {
  return;
 }
 targets.remove(to);
 if (targets.size() == 0) {
  sources.remove(from);
 }
}

代码示例来源:origin: org.slf4j/jcl-over-slf4j

/**
   * Set the configuration attribute with the specified name. Calling this with
   * a <code>null</code> value is equivalent to calling
   * <code>removeAttribute(name)</code>.
   * 
   * @param name
   *          Name of the attribute to set
   * @param value
   *          Value of the attribute to set, or <code>null</code> to remove
   *          any setting for this attribute
   */
  @SuppressWarnings("unchecked")
  public void setAttribute(String name, Object value) {

    if (value == null) {
      attributes.remove(name);
    } else {
      attributes.put(name, value);
    }

  }
}

代码示例来源:origin: pentaho/pentaho-kettle

/**
 * Clear out all entries of database with a certain name
 *
 * @param dbname
 *          The name of the database for which we want to clear the cache or null if we want to clear it all.
 */
public void clear( String dbname ) {
 if ( dbname == null ) {
  cache = new Hashtable<DBCacheEntry, RowMetaInterface>();
  setActive();
 } else {
  Enumeration<DBCacheEntry> keys = cache.keys();
  while ( keys.hasMoreElements() ) {
   DBCacheEntry entry = keys.nextElement();
   if ( entry.sameDB( dbname ) ) {
    // Same name: remove it!
    cache.remove( entry );
   }
  }
 }
}

代码示例来源:origin: plutext/docx4j

/**
 * Removes the mapping associated to the specified prefix.
 *
 * @param prefix The prefix which mapping should be removed.
 */
private void removeIfNeeded(String prefix) {
 // remove the previous mapping to the prefix
 if (this.prefixMapping.containsValue(prefix)) {
  Object key = null;
  for (Enumeration<String> e = this.prefixMapping.keys(); e.hasMoreElements();) {
   key = e.nextElement();
   if (this.prefixMapping.get(key).equals(prefix)) {
    break;
   }
  }
  this.prefixMapping.remove(key); // we know key should have a value
 }
}

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

while(enumeration.hasMoreElements() && (misses <= 4)) {
Thread t = (Thread) enumeration.nextElement();
if(t.isAlive()) {
 misses++;
 Thread t = (Thread) v.elementAt(i);
 LogLog.debug("Lazy NDC removal for thread [" + t.getName() + "] ("+ 
    ht.size() + ").");
 ht.remove(t);

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

public void hashtablesCantContainNull(Hashtable h) {
    h.put("a", null);
    h.put(null, "a");
    h.get(null);
    h.contains(null);
    h.containsKey(null);
    h.containsValue(null);
    h.remove(null);

  }
}

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

public static void main(String[] args) {
   // TODO Auto-generated method stub
   Hashtable siCache = new Hashtable();
   siCache.put("key", "value");
   siCache.put("key1", "value1");
   Enumeration keys = siCache.keys();  //siCache is Hashtable
   while(keys.hasMoreElements())
   {
     String k = (String) keys.nextElement();
     Object v = siCache.get(k);
     if(true) siCache.remove(k);
   }
   System.out.println(siCache.size());
 }

代码示例来源:origin: Sable/soot

private boolean SSSPFinder(Object src) {
 Hashtable<Object, IntContainer> outedges = sources.get(src);
 if (outedges == null) {
  return true;
 if (outedges.size() == 0) {
  return true;
 distance.remove(src);
   WeightedDirectedEdge edge = edgeIt.next();
   IntContainer dfrom = distance.get(edge.from);
   IntContainer dto = distance.get(edge.to);
   if (dto == null) {
    continue;
  IntContainer dist = distance.get(to);
  outedges.put(to, dist.dup());

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

if (lock == null) {
  Object result = env.remove("org.mortbay.jndi.lock");
  if (result == null) {
    result = env.remove("org.eclipse.jndi.lock");
env.put("org.mortbay.jndi.lock", lock);
env.put("org.eclipse.jndi.lock", lock);

代码示例来源:origin: de.sciss/abc4j

public void removeListener (PropertyChangeListener listener) {
 if (listeners != null && listeners.size() > 0)
   listeners.remove(listener);
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Remove all flags in the given Flags object from this 
 * Flags object.
 *
 * @param    f     the flag to be removed
 */
public void remove(Flags f) {
system_flags &= ~f.system_flags; // remove system flags
if (f.user_flags != null) {
  if (user_flags == null)
  return;
  Enumeration<String> e = f.user_flags.keys();
  while (e.hasMoreElements())
  user_flags.remove(e.nextElement());
}
}

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

s_logger.debug("connMap=" + connMap);
Enumeration<String> e = connMap.keys();
while (e.hasMoreElements()) {
  String key;
  ConsoleProxyClient client;
    key = e.nextElement();
    client = connMap.get(key);
    connMap.remove(key);
    bReportLoad = true;

代码示例来源:origin: com.sun.mail/javax.mail

if (f.user_flags != null) {
Enumeration<String> e = user_flags.keys();
while (e.hasMoreElements()) {
  String key = e.nextElement();
  if (!f.user_flags.containsKey(key)) {
  user_flags.remove(key);
  changed = true;
changed = user_flags.size() > 0;
user_flags = null;

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

/**
 * Update references to a renamed job in the fingerprint
 */
public synchronized void rename(String oldName, String newName) throws IOException {
  boolean touched = false;
  if (original != null) {
    if (original.getName().equals(oldName)) {
      original.setName(newName);
      touched = true;
    }
  }
  
  if (usages != null) {
    RangeSet r = usages.get(oldName);
    if (r != null) {
      usages.put(newName, r);
      usages.remove(oldName);
      touched = true;
    }
  }
  
  if (touched) {
    save();
  }
}

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

/**
   * Set the configuration attribute with the specified name. Calling this with
   * a <code>null</code> value is equivalent to calling
   * <code>removeAttribute(name)</code>.
   * 
   * @param name
   *          Name of the attribute to set
   * @param value
   *          Value of the attribute to set, or <code>null</code> to remove
   *          any setting for this attribute
   */
  @SuppressWarnings("unchecked")
  public void setAttribute(String name, Object value) {

    if (value == null) {
      attributes.remove(name);
    } else {
      attributes.put(name, value);
    }

  }
}

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

/**
 * Set this required element found.
 *
 */
void setRequiredFound(String elem, boolean found)
{
 if (m_requiredFound.get(elem) != null) 
    m_requiredFound.remove(elem);
}

代码示例来源:origin: Sable/soot

public void killNode(Object tokill) {
 if (!this.vertexes.contains(tokill)) {
  return;
 }
 this.makeShortestPathGraph();
 List<Object> sourceList = new ArrayList<Object>(sources.keySet());
 Iterator<Object> srcIt = sourceList.iterator();
 while (srcIt.hasNext()) {
  Object src = srcIt.next();
  Hashtable targets = sources.get(src);
  /* delete the in edge */
  targets.remove(tokill);
  if (targets.size() == 0) {
   sources.remove(src);
  }
 }
 sources.remove(tokill);
 this.makeShortestPathGraph();
}

代码示例来源:origin: org.jbpm/jbpm-form-modeler-ui

@Override
public synchronized List getRenderingInstructions(String template) {
  if (template == null) {
    return Collections.EMPTY_LIST;
  }
  List l = (List) templatesCache.get(template);
  if (l == null) {
    l = calculateInstructions(template);
    if (templatesCache.size() > 50)
      templatesCache.remove(templatesCache.keySet().iterator().next());
    templatesCache.put(template, l);
  }
  return l;
}

代码示例来源:origin: jdfekete/geneaquilt

public void keyReleased(KeyEvent e) {
  //
  if (!keysDown.containsKey(e.getKeyCode()))
    return;
  keysDown.remove(e.getKeyCode());
  //
  if (keysDown.size() == 0 && autorepeat)
    keyRepeatTimer.stop();
  //
  delegate.keyReleased(e);
}

相关文章