java.util.HashSet.isEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(117)

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

HashSet.isEmpty介绍

[英]Returns true if this HashSet has no elements, false otherwise.
[中]如果此哈希集没有元素,则返回true,否则返回false。

代码示例

代码示例来源:origin: Tencent/tinker

public static boolean checkFileInPattern(HashSet<Pattern> patterns, String key) {
  if (!patterns.isEmpty()) {
    for (Iterator<Pattern> it = patterns.iterator(); it.hasNext();) {
      Pattern p = it.next();
      if (p.matcher(key).matches()) {
        return true;
      }
    }
  }
  return false;
}

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

private void closeReader(Reader r) throws IOException {
  synchronized (lock) {
    if (activeReaders.contains(r) == false)
      throw new IllegalStateException();
    activeReaders.remove(r);
    if (activeReaders.isEmpty())
      closeReadChannel();
  }
}

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

public boolean tryAddingOptionalUniqueAnnotations(BugAnnotation... annotations) {
  HashSet<BugAnnotation> added = new HashSet<>();
  for (BugAnnotation a : annotations) {
    if (a != null && added.add(a)) {
      add(a);
    }
  }
  return !added.isEmpty();
}

代码示例来源:origin: deeplearning4j/nd4j

public static Method getMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) {
  Assert.notNull(clazz, "Class must not be null");
  Assert.notNull(methodName, "Method name must not be null");
  if (paramTypes != null) {
    try {
      return clazz.getMethod(methodName, paramTypes);
    } catch (NoSuchMethodException var9) {
      throw new IllegalStateException("Expected method not found: " + var9);
    }
  } else {
    HashSet candidates = new HashSet(1);
    Method[] methods = clazz.getMethods();
    Method[] arr$ = methods;
    int len$ = methods.length;
    for (int i$ = 0; i$ < len$; ++i$) {
      Method method = arr$[i$];
      if (methodName.equals(method.getName())) {
        candidates.add(method);
      }
    }
    if (candidates.size() == 1) {
      return (Method) candidates.iterator().next();
    } else if (candidates.isEmpty()) {
      throw new IllegalStateException("Expected method not found: " + clazz + "." + methodName);
    } else {
      throw new IllegalStateException("No unique method found: " + clazz + "." + methodName);
    }
  }
}

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

outEdges.add(e);
 node.inEdges.add(e);
 return this;
for(Node n : allNodes){
 if(n.inEdges.size() == 0){
  S.add(n);
while(!S.isEmpty()){
 Node n = S.iterator().next();
 S.remove(n);
  Edge e = it.next();
  Node m = e.to;
  m.inEdges.remove(e);//Remove edge from m
  if(m.inEdges.isEmpty()){
   S.add(m);
 if(!n.inEdges.isEmpty()){
  cycle = true;
  break;

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

HashSet<String> hs = sd.ackPositions.get(sequenceId);
if (hs != null) {
  hs.remove(subscriptionKey);
  if (hs.isEmpty()) {
    HashSet<String> firstSet = sd.ackPositions.values().iterator().next();
    sd.ackPositions.remove(sequenceId);
        Entry<Long, MessageRecord> entry = iterator.next();
        if (entry.getKey().compareTo(sequenceId) <= 0) {

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

Map.Entry<String, JobSchedulerImpl> entry = i.next();
  JobSchedulerImpl scheduler = entry.getValue();
  Map.Entry<String, JobSchedulerImpl> entry = i.next();
  JobSchedulerImpl scheduler = entry.getValue();
    missingJournalFiles.add(job.getLocation().getDataFileId());
    if (job.getLastUpdate() != null) {
      missingJournalFiles.add(job.getLastUpdate().getDataFileId());
if (!missingJournalFiles.isEmpty()) {
  LOG.info("Some journal files are missing: {}", missingJournalFiles);
    int id = dataFile.getDataFileId();
    for (long offset : dataFile.getCorruptedBlocks()) {
      corruptedLocations.add(new Location(id, (int) offset));
  if (!corruptedLocations.isEmpty()) {
    LOG.debug("Found some corrupted data blocks in the journal: {}", corruptedLocations.size());
if (!missingJournalFiles.isEmpty() || !corruptedLocations.isEmpty()) {
  if (!isIgnoreMissingJournalfiles()) {
    throw new IOException("Detected missing/corrupt journal files.");

代码示例来源:origin: ankidroid/Anki-Android

private void onCheck(int position, View cell) {
  CheckBox checkBox = (CheckBox) cell.findViewById(R.id.card_checkbox);
  if (checkBox.isChecked()) {
    mCheckedCardPositions.add(position);
  } else {
    mCheckedCardPositions.remove(position);
  }
  updateMultiselectMenu();
  if (mCheckedCardPositions.isEmpty()) {
    // when 0 are selected: end selection mode
    endMultiSelectMode();
  } else {
    mActionBarTitle.setText(Integer.toString(mCheckedCardPositions.size()));
  }
}

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

else if (!F.eq(grpDesc.deploymentId(), curGrpDesc.deploymentId())) {
    return errorFuture("Cannot change WAL mode for caches from different cache groups [" +
      "cache1=" + cacheNames.iterator().next() + ", grp1=" + grpDesc.groupName() +
      ", cache2=" + cacheName + ", grp2=" + curGrpDesc.groupName() + ']');
if (!grpCaches.isEmpty()) {
  return errorFuture("Cannot change WAL mode because not all cache names belonging to the group are " +
    "provided [group=" + grpDesc.groupName() + ", missingCaches=" + grpCaches + ']');

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

/**
 * Given a column name and a set of pdx types, find the field name in those types that match,
 * ignoring case, the column name.
 *
 * @return the matching field name or null if no match
 * @throws JdbcConnectorException if no fields match
 * @throws JdbcConnectorException if more than one field matches
 */
private String findCaseInsensitiveMatch(String columnName, Set<PdxType> pdxTypes) {
 HashSet<String> matchingFieldNames = new HashSet<>();
 for (PdxType pdxType : pdxTypes) {
  for (String existingFieldName : pdxType.getFieldNames()) {
   if (existingFieldName.equalsIgnoreCase(columnName)) {
    matchingFieldNames.add(existingFieldName);
   }
  }
 }
 if (matchingFieldNames.isEmpty()) {
  throw new JdbcConnectorException("The class " + getPdxName()
    + " does not have a field that matches the column " + columnName);
 } else if (matchingFieldNames.size() > 1) {
  throw new JdbcConnectorException(
    "Could not determine what pdx field to use for the column name " + columnName
      + " because the pdx fields " + matchingFieldNames + " all match it.");
 }
 return matchingFieldNames.iterator().next();
}

代码示例来源:origin: Tencent/tinker

public static boolean checkFileInPattern(HashSet<Pattern> patterns, String key) {
  if (!patterns.isEmpty()) {
    for (Iterator<Pattern> it = patterns.iterator(); it.hasNext();) {
      Pattern p = it.next();
      if (p.matcher(key).matches()) {
        return true;
      }
    }
  }
  return false;
}

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

if (t instanceof AnySubType) {
 HashSet<SootClass> s = new HashSet<SootClass>();
 s.add(declaringClass);
 while (!s.isEmpty()) {
  SootClass c = s.iterator().next();
  s.remove(c);
  if (!c.isInterface() && !c.isAbstract() && canStoreClass(c, declaringClass)) {
   SootMethod concreteM = resolveConcreteDispatch(c, m);

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

candidates.remove(self.getId()); // if we're here, I shouldn't be the leader
long curCandidate = candidates.iterator().next();
Proposal p = outstandingProposals.get(curZxid);
while (p!=null && !candidates.isEmpty()) {
  for (Proposal.QuorumVerifierAcksetPair qvAckset: p.qvAcksetPairs){
    if (candidates.isEmpty()) return curCandidate;
    curCandidate = candidates.iterator().next();
    if (candidates.size() == 1) return curCandidate;

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

public void execute() throws Pausable {
  while (!tasks.isEmpty() || addedTasksMB.hasMessage()) {
    switch (Mailbox.select(addedTasksMB, exitmb)) {
    case 0: 
      Task t = addedTasksMB.getnb();
      t.informOnExit(exitmb);
      tasks.add(t);
      break;
    case 1: 
      ExitMsg em = exitmb.getnb();
      results.add(em);
      tasks.remove(em.task);
      break;
    }
  }
  exit(results);
}

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

public BugInstance addOptionalUniqueAnnotationsWithFallback(BugAnnotation fallback, BugAnnotation... annotations) {
  HashSet<BugAnnotation> added = new HashSet<>();
  for (BugAnnotation a : annotations) {
    if (a != null && added.add(a)) {
      add(a);
    }
  }
  if (added.isEmpty()) {
    add(fallback);
  }
  return this;
}

代码示例来源:origin: com.h2database/h2

@Override
public void unlock(Session s) {
  if (database != null) {
    traceLock(s, lockExclusiveSession == s, "unlock");
    if (lockExclusiveSession == s) {
      lockExclusiveSession = null;
    }
    synchronized (database) {
      if (!lockSharedSessions.isEmpty()) {
        lockSharedSessions.remove(s);
      }
      if (!waitingSessions.isEmpty()) {
        database.notifyAll();
      }
    }
  }
}

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

Map.Entry me = (Map.Entry) it.next();
RegionCommitList rcl = (RegionCommitList) me.getValue();
if (rcl.getNeedsAck()) {
  ackReceivers = new HashSet();
 ackReceivers.add(me.getKey());
 distMap.put(rcl, receivers);
receivers.add(me.getKey());
 Map.Entry me = (Map.Entry) it.next();
 RegionCommitList rcl = (RegionCommitList) me.getKey();
 HashSet recipients = (HashSet) me.getValue();
 if (!recipients.isEmpty()) {
  if (this.txState.internalDuringIndividualSend != null) {
   while (indivRecip.hasNext()) {
    this.txState.internalDuringIndividualSend.run();
    setRecipientsSendData(Collections.singleton(indivRecip.next()), processor, rcl);

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

Expression(Node content) {
  this.content = content;
  HashSet<String> strings = new HashSet<>();
  content.catalog(strings);
  referencedStrings = strings.isEmpty() ? Collections.emptySet() : strings.size() == 1 ? Collections.singleton(strings.iterator().next()) : Collections.unmodifiableSet(strings);
}

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

if (t instanceof AnySubType) {
 HashSet<SootClass> s = new HashSet<SootClass>();
 s.add(declaringClass);
 while (!s.isEmpty()) {
  SootClass c = s.iterator().next();
  s.remove(c);
  if (!c.isInterface() && !c.isAbstract() && canStoreClass(c, declaringClass)) {
   SootMethod concreteM = resolveConcreteDispatch(c, m);

代码示例来源:origin: fesh0r/fernflower

setPreds.remove(first);
if (!setPreds.isEmpty()) {
 Statement pred =
  setPreds.iterator().next(); // assumption: at most one predecessor node besides the head. May not hold true for obfuscated code.
 for (int j = 0; j < nodes.size(); j++) {
  if (j != (index - 1) && nodes.get(j) == pred) {
 edge.closure.getLabelEdges().remove(edge);

相关文章