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

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

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

Hashtable.containsKey介绍

[英]Returns true if this Hashtable contains the specified object as a key of one of the key/value pairs.
[中]如果此哈希表包含作为其中一个键/值对的键的指定对象,则返回true。

代码示例

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

/**
 * {@inheritDoc}
 */
public PDGNode getPDGNode(Object cfgNode) {
 if (cfgNode != null && cfgNode instanceof Block) {
  if (this.m_obj2pdgNode.containsKey(cfgNode)) {
   return this.m_obj2pdgNode.get(cfgNode);
  }
 }
 return null;
}

代码示例来源:origin: eclipsesource/J2V8

@Override
public V put(final String key, final V value) {
  if (value == null) {
    if (map.containsKey(key)) {
      map.remove(key);
    }
    nulls.add(key);
    return null;
  }
  if (nulls.contains(key)) {
    nulls.remove(key);
  }
  return map.put(key, value);
}

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

public final void topoSort(final CaseInsensitiveString root, final PipelineDependencyState pipelineDependencyState) throws Exception {
  Hashtable<CaseInsensitiveString, CycleState> state = new Hashtable<>();
  Stack<CaseInsensitiveString> visiting = new Stack<>();
  if (!state.containsKey(root)) {
    tsort(root, pipelineDependencyState, state, visiting);
  } else if (state.get(root) == CycleState.VISITING) {
    throw ExceptionUtils.bomb("Unexpected node in visiting state: " + root);
  }
  assertHasVisitedAllNodesInTree(state);
}

代码示例来源:origin: javax.servlet/servlet-api

throw new IllegalArgumentException();
Hashtable ht = new Hashtable();
StringBuffer sb = new StringBuffer();
StringTokenizer st = new StringTokenizer(s, "&");
  if (ht.containsKey(key)) {
  String oldVals[] = (String []) ht.get(key);
  valArray = new String[oldVals.length + 1];
  for (int i = 0; i < oldVals.length; i++) 
  valArray[0] = val;
  ht.put(key, valArray);

代码示例来源:origin: oblac/jodd

@Test
void testAsIterator_with_data() throws Exception {
  final Hashtable<String, String> input = new Hashtable<>();
  input.put("jodd", "makes fun!");
  input.put("headline", "The Unbearable Lightness of Java");
  input.put("aim", "And enjoy the coding");
  final Iterator<String> actual = CollectionUtil.asIterator(input.keys());
  // asserts
  assertNotNull(actual);
  // next #1
  assertTrue(actual.hasNext());
  String key = actual.next();
  assertTrue(input.containsKey(key));
  // next #2
  assertTrue(actual.hasNext());
  key = actual.next();
  assertTrue(input.containsKey(key));
  // next #3
  assertTrue(actual.hasNext());
  key = actual.next();
  assertTrue(input.containsKey(key));
  // no more elements
  assertFalse(actual.hasNext());
  assertThrows(NoSuchElementException.class, () -> {actual.next();});
}

代码示例来源: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: xalan/xalan

/**
 * This method starts at a given node, traverses all namespace mappings,
 * and assembles a list of all prefixes that (for the given node) maps
 * to _ANY_ namespace URI. Used by literal result elements to determine
 */
public Enumeration getNamespaceScope(SyntaxTreeNode node) {
Hashtable all = new Hashtable();

while (node != null) {
  Hashtable mapping = node.getPrefixMapping();
  if (mapping != null) {
  Enumeration prefixes = mapping.keys();
  while (prefixes.hasMoreElements()) {
    String prefix = (String)prefixes.nextElement();
    if (!all.containsKey(prefix)) {
    all.put(prefix, mapping.get(prefix));
    }
  }
  }
  node = node.getParent();
}
return(all.keys());
}

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

Hashtable<String, Object> currentMaps = new Hashtable<String, Object>();
for ( int i = 0; i < tableViewFields.table.getItemCount(); i++ ) {
 currentMaps.put( tableViewFields.table.getItem( i ).getText( 1 ) + tableViewFields.table.getItem( i ).getText( 2 )
  + tableViewFields.table.getItem( i ).getText( 3 ), true );
for ( FieldMapping map : mappings ) {
 if ( !currentMaps.containsKey( map.target_field_label + map.target_model + map.target_field ) ) {
  tableViewFields.add( map.target_field_label, map.target_model, map.target_field, map.source_model,
   map.source_field, String.valueOf( map.source_index ), String.valueOf( map.target_field_type ) );

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

public void checkedPut(final long id, final int type, final int hash)
{
  _size++;
  final TestKey item = new TestKey(id, type, hash);
  if (!_items.containsKey(type))
  {
    _items.put(type, new LinkedList<>());
  }
  _items.get(type).add(item);
}

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

if (!uidTable.containsKey(uid)) {
  uidTable = new Hashtable<Long, IMAPMessage>();
  msgs[i] = (Message)uidTable.get(Long.valueOf(uids[i]));
return msgs;

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

/**
 * Register a nuew connection pool to the global pool table.
 * If a pool by that name currently exists, then throw an
 * IllegalArgumentException stating that the pool already
 * exist.
 * @param name
 * @param pool
 *
 * @link org.apache.xalan.lib.sql.ConnectionPool}
 *
 * @throws <code>IllegalArgumentException</code>, throw this exception
 * if a pool with the same name currently exists.
 */
public synchronized void registerPool( String name, ConnectionPool pool )
{
 if ( m_poolTable.containsKey(name) )
 {
  throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_POOL_EXISTS, null)); //"Pool already exists");
 }
 m_poolTable.put(name, pool);
}

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

public boolean hasEdge(Object from, Object to) {
 Hashtable targets = sources.get(from);
 if (targets == null) {
  return false;
 }
 return targets.containsKey(to);
}

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

handler2header.put(handler, pred);
 if (try2nop.containsKey(trap.getBeginUnit())) {
  ehnop = try2nop.get(trap.getBeginUnit());
 } else {
  ehnop = new EHNopStmt();
  try2nop.put(trap.getBeginUnit(), ehnop);
Hashtable<Unit, Boolean> nop2added = new Hashtable<Unit, Boolean>();
 Unit b = trap.getBeginUnit();
 Unit handler = trap.getHandlerUnit();
 handler = handler2header.get(handler);
 Unit ehnop = try2nop.get(b);
 if (!nop2added.containsKey(ehnop)) {
  List<Unit> predsOfB = getPredsOf(b);
  List<Unit> predsOfehnop = new ArrayList<Unit>(predsOfB);
 nop2added.put(ehnop, Boolean.TRUE);

代码示例来源:origin: crashub/crash

String rest = prefix.substring(colon + 1);
int prev = 0;
Hashtable<String, String> keyValues = new Hashtable<String, String>();
while (true) {
 int next = rest.indexOf(',', prev);
   for (ObjectName name : completions) {
    for (String key : name.getKeyPropertyList().keySet()) {
     if (!keyValues.containsKey(key) && key.startsWith(keyValue[0])) {
      b.add(key.substring(keyValue[0].length()) + "=", false);
  keyValues.put(keyValue[0], keyValue[1]);
  prev = next + 1;

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

public void checkedPut(final long id, final int type, final int hash)
{
  _size++;
  final TestKey item = new TestKey(id, type, hash);
  if (!_items.containsKey(type))
  {
    _items.put(type, new LinkedList<>());
  }
  _items.get(type).add(item);
}

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

if (!uidTable.containsKey(uid)) {
  uidTable = new Hashtable<>();
  msgs[i] = (Message)uidTable.get(Long.valueOf(uids[i]));
return msgs;

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

/**
 * @see java.security.IdentityScope#addIdentity(java.security.Identity)
 */
public synchronized void addIdentity(Identity identity) throws KeyManagementException {
  if (identity == null) {
    throw new NullPointerException("identity == null");
  }
  String name = identity.getName();
  if (names.containsKey(name)) {
    throw new KeyManagementException("name '" + name + "' is already used");
  }
  PublicKey key = identity.getPublicKey();
  if (key != null && keys.containsKey(key)) {
    throw new KeyManagementException("key '" + key + "' is already used");
  }
  names.put(name, identity);
  if (key != null) {
    keys.put(key, identity);
  }
}

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

public Node getDependencyMaterialsFor(CaseInsensitiveString pipelineName) {
  if (getDependencies().containsKey(pipelineName)) {
    return getDependencies().get(pipelineName);
  }
  return new Node(new ArrayList<>());
}

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

pdgnode = this.m_obj2pdgNode.get(r);
 if (!this.m_obj2pdgNode.containsKey(a)) {
  pdgNodeOfA = new PDGNode(a, PDGNode.Type.CFGNODE);
  this.addNode(pdgNodeOfA);
  this.m_obj2pdgNode.put(a, pdgNodeOfA);
 } else {
  pdgNodeOfA = this.m_obj2pdgNode.get(a);
  Region regionOfB = block2region.get(b);
  PDGNode pdgnodeOfBRegion = null;
  if (!this.m_obj2pdgNode.containsKey(regionOfB)) {
   pdgnodeOfBRegion = new PDGNode(regionOfB, PDGNode.Type.REGION);
   this.addNode(pdgnodeOfBRegion);
    if (!this.m_obj2pdgNode.containsKey(rdepB)) {
     pdgnodeOfdepBRegion = new PDGNode(rdepB, PDGNode.Type.REGION);
     this.addNode(pdgnodeOfdepBRegion);
    if (!this.m_obj2pdgNode.containsKey(rdepB)) {
     pdgnodeOfdepBRegion = new PDGNode(rdepB, PDGNode.Type.REGION);
     this.addNode(pdgnodeOfdepBRegion);
   } else {
    PDGNode predPDGofdepB = (PDGNode) this.getPredsOf(depBPDGNode).get(0);
    assert (this.m_obj2pdgNode.containsKey(rdepB));

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

public static void deleteDups (LinkedListNode n){
 Hashtable table = new Hashtable();
 LinkedListNode previous = null;
 while(n!=null){
   if(table.containsKey(n.data)){
     previous.next = n.next;
   } else {
     table.put(n.data, true);
     previous = n;
   }
   n = n.next;
 }
}

相关文章