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

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

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

HashSet.removeIf介绍

暂无

代码示例

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

@Override
public void addSummarizers(String tableName, SummarizerConfiguration... newConfigs)
  throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
 HashSet<SummarizerConfiguration> currentConfigs = new HashSet<>(
   SummarizerConfiguration.fromTableProperties(getProperties(tableName)));
 HashSet<SummarizerConfiguration> newConfigSet = new HashSet<>(Arrays.asList(newConfigs));
 newConfigSet.removeIf(currentConfigs::contains);
 Set<String> newIds = newConfigSet.stream().map(SummarizerConfiguration::getPropertyId)
   .collect(toSet());
 for (SummarizerConfiguration csc : currentConfigs) {
  if (newIds.contains(csc.getPropertyId())) {
   throw new IllegalArgumentException("Summarizer property id is in use by " + csc);
  }
 }
 Set<Entry<String,String>> es = SummarizerConfiguration.toTableProperties(newConfigSet)
   .entrySet();
 for (Entry<String,String> entry : es) {
  setProperty(tableName, entry.getKey(), entry.getValue());
 }
}

代码示例来源:origin: io.snamp/internal-services

@Override
public final boolean removeIf(final Predicate<? super E> filter) {
  final boolean removed = super.removeIf(filter);
  modified |= removed;
  return removed;
}

代码示例来源:origin: net.fushizen.invokedynamic.proxy/invokedynamic-proxy

public void add(Method m) {
  if ((m.getModifiers() & Modifier.ABSTRACT) != 0) return;
  // Remove any concrete implementations that come from superclasses of the class that owns this new method
  // (this new class shadows them).
  contributors.removeIf(m2 -> m2.getDeclaringClass().isAssignableFrom(m.getDeclaringClass()));
  // Conversely, if this new implementation is shadowed by any existing implementations, we'll drop it instead
  if (contributors.stream().anyMatch(m2 -> m.getDeclaringClass().isAssignableFrom(m2.getDeclaringClass()))) {
    return;
  }
  contributors.add(m);
}

代码示例来源:origin: com.premiumminds/pm-wicket-utils

private static Method[] initMethods() {
  HashSet<Method> aux = new HashSet<Method>(Arrays.asList(RequestTargetTester.class.getDeclaredMethods()));
  aux.remove(getMethodHelper("addListener", AjaxRequestTarget.IListener.class));
  aux.remove(getMethodHelper("respond", IRequestCycle.class));
  aux.remove(getMethodHelper("detach", IRequestCycle.class));
  aux.removeIf(m -> m.isSynthetic());
  return aux.toArray(new Method[aux.size()]);
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
public void writeRestrictions(String oakPath, Tree aceTree, Set<Restriction> restrictions) throws RepositoryException {
  Sets.newHashSet(restrictions).removeIf(r -> REP_NODE_PATH.equals(r.getDefinition().getName()));
  base.writeRestrictions(oakPath, aceTree, restrictions);
}

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

@Override
public void writeRestrictions(String oakPath, Tree aceTree, Set<Restriction> restrictions) throws RepositoryException {
  Sets.newHashSet(restrictions).removeIf(r -> REP_NODE_PATH.equals(r.getDefinition().getName()));
  base.writeRestrictions(oakPath, aceTree, restrictions);
}

代码示例来源:origin: org.apereo.cas/cas-server-support-ldap

/**
   * Initialize the handler, setup the authentication entry attributes.
   */
  public void initialize() {
    /*
     * Use a set to ensure we ignore duplicates.
     */
    val attributes = new HashSet<String>();
    LOGGER.debug("Initializing LDAP attribute configuration...");
    if (StringUtils.isNotBlank(this.principalIdAttribute)) {
      LOGGER.debug("Configured to retrieve principal id attribute [{}]", this.principalIdAttribute);
      attributes.add(this.principalIdAttribute);
    }
    if (this.principalAttributeMap != null && !this.principalAttributeMap.isEmpty()) {
      val attrs = this.principalAttributeMap.keySet();
      attributes.addAll(attrs);
      LOGGER.debug("Configured to retrieve principal attribute collection of [{}]", attrs);
    }
    if (authenticator.getReturnAttributes() != null) {
      val authenticatorAttributes = CollectionUtils.wrapList(authenticator.getReturnAttributes());
      if (!authenticatorAttributes.isEmpty()) {
        LOGGER.debug("Filtering authentication entry attributes [{}] based on authenticator attributes [{}]", authenticatedEntryAttributes, authenticatorAttributes);
        attributes.removeIf(authenticatorAttributes::contains);
      }
    }
    this.authenticatedEntryAttributes = attributes.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
    LOGGER.debug("LDAP authentication entry attributes for the authentication request are [{}]", (Object[]) this.authenticatedEntryAttributes);
  }
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

private void findTargettedModules(char[] prefix, HashSet<String> skipSet) {
  HashSet<String> probableModules = new HashSet<>();
  ModuleSourcePathManager mManager = JavaModelManager.getModulePathManager();
  JavaElementRequestor javaElementRequestor = new JavaElementRequestor();
  try {
    mManager.seekModule(this.completionToken, true, javaElementRequestor);
    IModuleDescription[] modules = javaElementRequestor.getModules();
    for (IModuleDescription module : modules) {
      String name = module.getElementName();
      if (name == null || name.equals("")) //$NON-NLS-1$
        continue;
      probableModules.add(name);
    }
  } catch (JavaModelException e) {
    // TODO ignore for now
  }
  probableModules.addAll(getAllJarModuleNames(this.javaProject));
  if (prefix != CharOperation.ALL_PREFIX && prefix != null && prefix.length > 0) {
    probableModules.removeIf(e -> isFailedMatch(prefix, e.toCharArray()));
  }
  for (String s : probableModules) {
    if (!skipSet.contains(s))
      this.acceptModule(s.toCharArray());
  }
}
private void findTargettedModules(CompletionOnModuleReference moduleReference, HashSet<String> skipSet) {

代码示例来源:origin: io.github.factoryfx/javascript

reachableClasses.removeIf(this::isBuiltIn);
reachableClasses.removeIf(Class::isArray);
reachableClasses.removeIf(Class::isPrimitive);
reachableClasses.forEach(r->{
  if (!classesAlreadyDeclared.contains(r)) {

代码示例来源:origin: girtel/Net2Plan

public int getIndex(Graph<GUINode,GUILink> graph, GUILink e) 
  {
    final GUINode u = e.getOriginNode();
    final GUINode v = e.getDestinationNode();
    final HashSet<GUILink> commonEdgeSet = new HashSet<>(graph.getInEdges(v));
    commonEdgeSet.retainAll(graph.getOutEdges(u));
    commonEdgeSet.removeIf(ee->!ee.isShownSeparated());
    int count=0;
    for(GUILink other : commonEdgeSet) 
      if (other == e)
        return count;
      else
        count ++;
    throw new RuntimeException();
  }
});

代码示例来源:origin: nats-io/java-nats

pureSubscribers.removeIf((s) -> {
  return s.getDispatcher() != null;
});

代码示例来源:origin: io.nats/jnats

pureSubscribers.removeIf((s) -> {
  return s.getDispatcher() != null;
});

代码示例来源:origin: TeamWizardry/Wizardry

@SubscribeEvent
public static void worldTick(TickEvent.WorldTickEvent event) {
  if (event.phase == TickEvent.Phase.START)
    reversals.removeIf((reversal) -> {
      if (reversal.world.get() == event.world) {
        if (reversal.nemez.hasNext()) {
          reversal.nemez.applySnapshot(event.world);
          if (reversal.pos != null && reversal.world.get().getTotalWorldTime() % PacketNemezReversal.SYNC_AMOUNT == 0)
            PacketHandler.NETWORK.sendToAllAround(new PacketNemezReversal(reversal.nemez),
                new NetworkRegistry.TargetPoint(reversal.world.get().provider.getDimension(),
                    reversal.pos.getX() + 0.5, reversal.pos.getY() + 0.5, reversal.pos.getZ() + 0.5, 96));
        } else {
          for (Entity entity : reversal.nemez.getTrackedEntities(event.world))
            entity.setNoGravity(false);
          return true;
        }
      }
      return reversal.world.get() == null;
    });
}

代码示例来源:origin: de.mhus.lib/mhu-lib-core

public void doQueueCheck() {
  log().d("doQueueCheck");
  lastQueueCheck = System.currentTimeMillis();
  synchronized (running) {
    synchronized (jobs) {
      jobs.removeIf(j -> {
        return j.isCanceled();
      });
      jobs.forEach(j -> {
        if (!queue.contains(j) && !running.contains(j)) {
          try {
            log().w("reschedule lost job",j.getName());
            j.setNextExecutionTime(SchedulerJob.CALCULATE_NEXT);
            j.doSchedule(this);
          } catch (Throwable t) {
            log().w("reschedule failed",j,t);
          }
        }
      });
    }
  }
}

相关文章