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

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

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

HashSet.clear介绍

[英]Removes all elements from this HashSet, leaving it empty.
[中]删除此哈希集中的所有元素,使其为空。

代码示例

代码示例来源:origin: prolificinteractive/material-calendarview

/**
  * We're changing the dates, so make sure to call {@linkplain MaterialCalendarView#invalidateDecorators()}
  */
 public void addFirstAndLast(final CalendarDay first, final CalendarDay last) {
  list.clear();
  list.add(first);
  list.add(last);
 }
}

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

public HashSet<Statement> buildContinueSet() {
 continueSet.clear();
 for (Statement st : stats) {
  continueSet.addAll(st.buildContinueSet());
  if (st != first) {
   continueSet.remove(st.getBasichead());
  }
 }
 for (StatEdge edge : getEdges(StatEdge.TYPE_CONTINUE, DIRECTION_FORWARD)) {
  continueSet.add(edge.getDestination().getBasichead());
 }
 if (type == TYPE_DO) {
  continueSet.remove(first.getBasichead());
 }
 return continueSet;
}

代码示例来源:origin: google/ExoPlayer

private void removeUnusedDurationEntries(List<MediaQueueItem> items) {
  scratchContentIdSet.clear();
  for (MediaQueueItem item : items) {
   scratchContentIdSet.add(item.getMedia().getContentId());
  }
  contentIdToDurationUsMap.keySet().retainAll(scratchContentIdSet);
 }
}

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

bucketId.clear();
bucketId.add(bucket);
try {
 if (entry.getKey().getVersionObject().compareTo(Version.GFE_80) < 0) {
 failures.add(bucket);

代码示例来源:origin: opentripplanner/OpenTripPlanner

public void removeEdge(AreaEdge edge) {
  edges.remove(edge);
  // reconstruct vertices
  vertices.clear();
  for (Edge e : edges) {
    vertices.add((IntersectionVertex) e.getFromVertex());
  }
}

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

setHandlers.add(head);
while (true) {
     setNodes.add(st);
     if (st != head) {
setHandlers.clear();
for (Statement st : setNodes) {
 setHandlers.addAll(st.getNeighbours(StatEdge.TYPE_EXCEPTION, Statement.DIRECTION_FORWARD));

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

private void onCheckAll() {
  boolean all = mCheckedCardPositions.size() < getCards().size();
  if (all) {
    for (int i = 0; i < mCards.size(); i++) {
      mCheckedCardPositions.add(i);
    }
  } else {
    mCheckedCardPositions.clear();
  }
  updateMultiselectMenu();
  mActionBarTitle.setText(Integer.toString(mCheckedCardPositions.size()));
  mCardsAdapter.notifyDataSetChanged();
}

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

for (ResourceRoot resourceRoot : resourceRoots) {
  if (resourceRoot.getRoot().getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
    jarsSet.add(resourceRoot.getRootName());
    jarsSet.clear();
    throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.invalidRelativeOrdering(), e);
  jarsSet.clear();
} else {
  jarsSet.clear();
  warMetaData.setNoOrder(true);

代码示例来源:origin: oracle/opengrok

/**
 * Web address consisting of webappURI and port of a web address
 */
public static class WebAddress {
  private String host;
  private int port;
  WebAddress(String host, String port) throws NumberFormatException {
    this.host = host;
    this.port = Integer.parseInt(port);
  }
  public String getHost() {
    return host;
  }
  public int getPort() {
    return port;
  }
}

代码示例来源:origin: android-hacker/VirtualXposed

duplicates.add(startApp);
for (int j = start + 1; j <= end; j++) {
  ResolveInfo jRi = rList.get(j);
    break;
  } else {
    duplicates.add(jApp);
duplicates.clear();

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

classNDexInfo.clear();
    testInfo = info;
  } else if (isVmArt && ShareConstants.CLASS_N_PATTERN.matcher(info.realName).matches()) {
    classNDexInfo.add(info);
  } else {
    dexes.put(info.realName, getInfoMd5(info));
  && (testInfo != null || !classNDexInfo.isEmpty())) {
  if (testInfo != null) {
    classNDexInfo.add(ShareTinkerInternals.changeTestDexToClassN(testInfo, classNDexInfo.size() + 1));

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

public Set<String> getSurroundingCaughtExceptions(int pc, int maxTryBlockSize) {
  HashSet<String> result = new HashSet<>();
  if (code == null) {
    throw new IllegalStateException("Not visiting Code");
  }
  int size = maxTryBlockSize;
  if (code.getExceptionTable() == null) {
    return result;
  }
  for (CodeException catchBlock : code.getExceptionTable()) {
    int startPC = catchBlock.getStartPC();
    int endPC = catchBlock.getEndPC();
    if (pc >= startPC && pc <= endPC) {
      int thisSize = endPC - startPC;
      if (size > thisSize) {
        result.clear();
        size = thisSize;
        result.add("C" + catchBlock.getCatchType());
      } else if (size == thisSize) {
        result.add("C" + catchBlock.getCatchType());
      }
    }
  }
  return result;
}

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

Log.w(TAG, "Clear all circles, size is " + mCircles.size());
  mCircles.clear();
mCircles.add(touchedCircle);

代码示例来源:origin: google/cameraview

@Test
public void testHashCode() {
  int max = 100;
  HashSet<Integer> codes = new HashSet<>();
  for (int x = 1; x <= 100; x++) {
    codes.add(AspectRatio.of(x, 1).hashCode());
  }
  assertThat(codes.size(), is(max));
  codes.clear();
  for (int y = 1; y <= 100; y++) {
    codes.add(AspectRatio.of(1, y).hashCode());
  }
  assertThat(codes.size(), is(max));
}

代码示例来源:origin: ehcache/ehcache3

@Test
 @SuppressWarnings("unchecked")
 public void testRankCachingTier() throws Exception {
  CompoundCachingTier.Provider provider = new CompoundCachingTier.Provider();
  HashSet<ResourceType<?>> resourceTypes = new HashSet<>(EnumSet.of(ResourceType.Core.HEAP, ResourceType.Core.OFFHEAP));
  assertThat(provider.rankCachingTier(resourceTypes, EMPTY_LIST), is(2));

  resourceTypes.clear();
  resourceTypes.add(new UnmatchedResourceType());
  assertThat(provider.rankCachingTier(resourceTypes, EMPTY_LIST), is(0));
 }
}

代码示例来源:origin: dermotte/LIRE

private void createRandomNeighbourhood() {
  randomNeighbourhood.clear();
  while (randomNeighbourhood.size() < neighbourhoodSize) {
    int n = (int) (Math.random() * possibleNeighbours.length);
    if (n == possibleNeighbours.length) n--;
    randomNeighbourhood.add(n);
  }
}

代码示例来源:origin: dermotte/LIRE

private void createRandomNeighbourhood() {
  randomNeighbourhood.clear();
  while (randomNeighbourhood.size() < neighbourhoodSize) {
    int n = (int) (Math.random() * possibleNeighbours.length);
    if (n == possibleNeighbours.length) n--;
    randomNeighbourhood.add(n);
  }
}

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

switch (randomFrom(ops)) {
 case ADD:
  assertEquals(reference.add(k), base.add(k));
  break;
  reference.clear();
  base.clear();
  break;

代码示例来源:origin: zstackio/zstack

@Override
  public void updateGlobalConfig(GlobalConfig oldConfig, GlobalConfig newConfig) {
    accountApiControl.clear();
    if (newConfig.value().isEmpty()) {
      return;
    }
    String[] classNames = newConfig.value().split(",");
    for (String name : classNames) {
      try {
        name = name.trim();
        Class clz = Class.forName(name);
        accountApiControl.add(clz);
      } catch (ClassNotFoundException e) {
        throw new CloudRuntimeException(e);
      }
    }
  }
});

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

private int calculateRequiredChannels()
{
  this.semiOpen.clear();
  int depth = 0;
  for( final IGridNode nodes : this.requireChannels )
  {
    if( !this.semiOpen.contains( nodes ) )
    {
      final IGridBlock gb = nodes.getGridBlock();
      final EnumSet<GridFlags> flags = gb.getFlags();
      if( flags.contains( GridFlags.COMPRESSED_CHANNEL ) && !this.blockDense.isEmpty() )
      {
        return 9;
      }
      depth++;
      if( flags.contains( GridFlags.MULTIBLOCK ) )
      {
        final IGridMultiblock gmb = (IGridMultiblock) gb;
        final Iterator<IGridNode> i = gmb.getMultiblockNodes();
        while( i.hasNext() )
        {
          this.semiOpen.add( (IPathItem) i.next() );
        }
      }
    }
  }
  return depth;
}

相关文章