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

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

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

Multiset.stream介绍

暂无

代码示例

代码示例来源:origin: goldmansachs/gs-collections

@Benchmark
public void serial_lazy_jdk()
{
  Map<Alphagram, List<String>> groupBy = this.guavaWords.stream().collect(Collectors.groupingBy(Alphagram::new));
  groupBy.entrySet()
      .stream()
      .map(Map.Entry::getValue)
      .filter(list -> list.size() >= SIZE_THRESHOLD)
      .sorted(Comparator.<List<String>>comparingInt(List::size).reversed())
      .map(list -> list.size() + ": " + list)
      .forEach(e -> Assert.assertFalse(e.isEmpty()));
}

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

/**
 * Given a filter and a set of rows, returns the subset of rows that match the filter
 *
 * @param filter The filter that should be matched
 * @param inputRows The input set of rows
 * @return A new set with matching rows
 */
@VisibleForTesting
static Multiset<Row> filterRows(Filter filter, Multiset<Row> inputRows) {
 return inputRows.stream()
   .filter(filter::matches)
   .collect(ImmutableMultiset.toImmutableMultiset());
}

代码示例来源:origin: kframework/k

@Override
public void visit(BuiltinSet builtinSet) {
  builtinSet.elements().stream().forEach(this::visitNode);
  builtinSet.baseTerms().stream().forEach(this::visitNode);
  visit((Collection) builtinSet);
}

代码示例来源:origin: OpenGamma/Strata

@Override
public Set<String> tokens(Iterable<?> iterable) {
 Multiset<String> tokens = HashMultiset.create();
 int index = 0;
 for (Object item : iterable) {
  tokens.add(String.valueOf(index++));
  tokens.addAll(fieldValues(item));
 }
 return tokens.stream()
   .filter(token -> tokens.count(token) == 1)
   .collect(toImmutableSet());
}

代码示例来源:origin: kframework/k

@Override
public void visit(BuiltinMap builtinMap) {
  builtinMap.getEntries().entrySet().stream().forEach(e -> {
    visitNode(e.getKey());
    visitNode(e.getValue());
  });
  builtinMap.baseTerms().stream().forEach(this::visitNode);
  visit((Collection) builtinMap);
}

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

/**
  * Selects specified columns from the Multiset of rows that is provided as input. A new set is
  * created and returned, and the input is not modified.
  *
  * @param columns The columns to select
  * @param inputRows The input set.
  * @returns A new set of rows with specified columns
  */
 @VisibleForTesting
 static Multiset<Row> selectColumns(Set<String> columns, Multiset<Row> inputRows) {
  return inputRows.stream()
    .map(row -> Row.builder().putAll(row, columns).build())
    .collect(ImmutableMultiset.toImmutableMultiset());
 }
}

代码示例来源:origin: protegeproject/webprotege

@Override
  public boolean matches(@Nonnull OWLEntity entity) {
    // Count languages by property
    Map<OWLAnnotationProperty, Multiset<String>> prop2Langs = new HashMap<>();
    axiomsIndex.getAnnotationAssertionAxioms(entity.getIRI())
          .filter(ax -> propertyMatcher.matches(ax.getProperty()))
          .filter(ax -> ax.getValue() instanceof OWLLiteral)
          .forEach(ax -> {
                    Multiset<String> langs = prop2Langs.computeIfAbsent(ax.getProperty(), p -> HashMultiset.create());
                    String lang = ((OWLLiteral) ax.getValue()).getLang();
                    langs.add(lang);
                  });
    return prop2Langs.values().stream()
             .anyMatch(langsForProp -> langsForProp.stream().anyMatch(lang -> langsForProp.count(lang) > 1));
  }
}

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

return table.getRows().getData().stream()
  .map(rowToInteger)
  .filter(Objects::nonNull)

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

@Override
public AnswerElement answer() {
 IpsecSessionStatusQuestion question = (IpsecSessionStatusQuestion) _question;
 Map<String, Configuration> configurations = _batfish.loadConfigurations();
 NetworkConfigurations networkConfigurations = NetworkConfigurations.of(configurations);
 ValueGraph<IpsecPeerConfigId, IpsecSession> ipsecTopology =
   IpsecUtil.initIpsecTopology(configurations);
 Set<String> initiatorNodes = question.getInitiatorRegex().getMatchingNodes(_batfish);
 Set<String> responderNodes = question.getResponderRegex().getMatchingNodes(_batfish);
 TableAnswerElement answerElement = new TableAnswerElement(createTableMetaData(question));
 Multiset<IpsecSessionInfo> ipsecSessionInfos =
   rawAnswer(networkConfigurations, ipsecTopology, initiatorNodes, responderNodes);
 answerElement.postProcessAnswer(
   question,
   ipsecSessionInfos.stream()
     .filter(
       ipsecSessionInfo ->
         question.matchesStatus(ipsecSessionInfo.getIpsecSessionStatus()))
     .map(IpsecSessionStatusAnswerer::toRow)
     .collect(Collectors.toCollection(HashMultiset::create)));
 return answerElement;
}

相关文章