com.google.common.collect.Multiset.forEach()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(123)

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

Multiset.forEach介绍

[英]Elements that occur multiple times in the multiset will be passed to the Consumercorrespondingly many times, though not necessarily sequentially.
[中]在multiset中多次出现的元素将相应地多次传递给使用者,尽管不一定是按顺序传递。

代码示例

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

@Override
public JsonElement toJson(Multiset sourceValue, Type typeOfT, JsonSerializationContext context) {
  JsonArray jsonArray = new JsonArray();
  sourceValue.forEach(e -> {
    jsonArray.add(context.serialize(e));
  });
  return jsonArray;
}

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

@Override
 public void disconnect() {
  synchronized (createdDeployments) {
   // Kills any executing deployment actions.
   createdDeployments.values().forEach(CancellableRunnable::cancel);
   createdDeployments
     .keys()
     .forEach(
       project ->
         ProjectManager.getInstance()
           .removeProjectManagerListener(project, projectClosingListener));
   createdDeployments.clear();
  }
 }
}

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

@Override
public AnswerElement answer() {
 DetectLoopsQuestion question = (DetectLoopsQuestion) _question;
 Set<Flow> flows = _batfish.bddLoopDetection();
 /*
  * There can be many flows exercising the same loop, so let's pick one per dstIp.
  */
 Multimap<Ip, Flow> flowsPerDst =
   flows.stream()
     .collect(
       Multimaps.toMultimap(Flow::getDstIp, Functions.identity(), HashMultimap::create));
 flows =
   flowsPerDst.asMap().values().stream()
     .flatMap(flowsWithSameDst -> flowsWithSameDst.stream().limit(1))
     .collect(Collectors.toSet());
 if (_batfish.debugFlagEnabled("oldtraceroute")) {
  FlowHistory flowHistory = _batfish.flowHistory(flows, false);
  Multiset<Row> rows = flowHistoryToRows(flowHistory);
  TableAnswerElement table = new TableAnswerElement(createMetadata(false));
  table.postProcessAnswer(_question, rows);
  return table;
 } else {
  SortedMap<Flow, List<Trace>> flowTraces = _batfish.buildFlows(flows, false);
  TableAnswerElement tableAnswer = new TableAnswerElement(TracerouteAnswerer.metadata(false));
  TracerouteAnswerer.flowTracesToRows(flowTraces, question.getMaxTraces())
    .forEach(tableAnswer::addRow);
  return tableAnswer;
 }
}

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

@Override
 public AnswerElement answer() {
  SpecifiersReachabilityQuestion question = (SpecifiersReachabilityQuestion) _question;
  AnswerElement answer = _batfish.standard(question.getReachabilityParameters());
  if (answer instanceof TraceWrapperAsAnswerElement) {
   TableAnswerElement tableAnswer = new TableAnswerElement(TracerouteAnswerer.metadata(false));
   TracerouteAnswerer.flowTracesToRows(
       ((TraceWrapperAsAnswerElement) answer).getFlowTraces(), question.getMaxTraces())
     .forEach(tableAnswer::addRow);
   return tableAnswer;
  } else if (answer instanceof FlowHistory) {
   TableAnswerElement tableAnswer =
     new TableAnswerElement(TracerouteAnswerer.createMetadata(false));
   TracerouteAnswerer.flowHistoryToRows((FlowHistory) answer, false)
     .forEach(tableAnswer::addRow);
   return tableAnswer;
  } else {
   return answer;
  }
 }
}

代码示例来源:origin: KleeGroup/vertigo

/**
 * Add all the classes with a package prefix in the scope.
 * @param packageName the root package
 * @return the selector
 */
public Selector from(final String packageName) {
  Assertion.checkArgNotEmpty(packageName);
  checkScope();
  // ---
  new Reflections(packageName,
      new TypeElementsScanner().includeAnnotations(false).includeFields(false).includeMethods(false))
          .getStore()
          .get(TypeElementsScanner.class.getSimpleName())
          .keys()
          .forEach(className -> from(ClassUtil.classForName(className)));
  return this;
}

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

@Override
public AnswerElement answer() {
 MultipathConsistencyParameters parameters = parameters();
 Set<Flow> flows = _batfish.bddMultipathConsistency(parameters);
 if (_batfish.debugFlagEnabled("oldtraceroute")) {
  FlowHistory flowHistory = _batfish.flowHistory(flows, false);
  Multiset<Row> rows = flowHistoryToRows(flowHistory);
  TableAnswerElement table = new TableAnswerElement(createMetadata(false));
  table.postProcessAnswer(_question, rows);
  return table;
 } else {
  SortedMap<Flow, List<Trace>> flowTraces = _batfish.buildFlows(flows, false);
  TableAnswerElement tableAnswer = new TableAnswerElement(TracerouteAnswerer.metadata(false));
  TracerouteAnswerer.flowTracesToRows(flowTraces, parameters.getMaxTraces())
    .forEach(tableAnswer::addRow);
  return tableAnswer;
 }
}

相关文章