java.util.TreeSet.stream()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(111)

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

TreeSet.stream介绍

暂无

代码示例

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

@Override
  public String toString() {
    return bugSet.stream().map(Object::toString).collect(Collectors.joining(",", "[", "]"));
  }
}

代码示例来源:origin: shekhargulati/99-problems

private Optional<Bin> findBin(TreeSet<Bin> bins, int weight) {
  return bins.stream().filter(b -> b.remaining() >= weight).findFirst();
}

代码示例来源:origin: RichardWarburton/java-8-lambdas-exercises

@GenerateMicroBenchmark
public int serialTreeSet() {
  return treeSet.stream().mapToInt(i -> i).sum();
}

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

@VisibleForTesting
static Set<byte[]> collectFamilies(List<Cell> cells) {
 if (CollectionUtils.isEmpty(cells)) {
  return Collections.emptySet();
 } else {
  return cells.stream()
     .filter(v -> !CellUtil.matchingFamily(v, WALEdit.METAFAMILY))
     .collect(toCollection(() -> new TreeSet<>(CellComparator.getInstance()::compareFamilies)))
     .stream()
     .map(CellUtil::cloneFamily)
     .collect(toCollection(() -> new TreeSet<>(Bytes.BYTES_COMPARATOR)));
 }
}

代码示例来源:origin: prestodb/presto

public Optional<Long> getDataSize()
  {
    if (type.getBase() == TpchColumnType.Base.VARCHAR) {
      return Optional.of(nonNullValues.stream()
          .map(String.class::cast)
          .mapToLong(String::length)
          .sum());
    }
    return Optional.empty();
  }
}

代码示例来源:origin: prestodb/presto

public Optional<Long> getDataSize()
  {
    if (type.getBase() == ColumnType.Base.VARCHAR || type.getBase() == ColumnType.Base.CHAR) {
      return Optional.of(nonNullValues.stream()
          .map(String.class::cast)
          .map(value -> {
            if (type.getBase() == ColumnType.Base.CHAR) {
              return value.replaceFirst(" +$", "");
            }
            return value;
          })
          .mapToLong(String::length)
          .sum());
    }
    return Optional.empty();
  }
}

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

public static void printCommands(TreeSet<KeywordExecutable> set, UsageGroup group) {
 set.stream().filter(e -> e.usageGroup() == group)
   .forEach(ke -> System.out.printf("  %-30s %s\n", ke.usage(), ke.description()));
}

代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.core

/**
 * Create a stream who is based on a defensive copy
 *
 * @return the stream
 */
public Stream<T> threadSafeStream() {
  return new TreeSet<>(this.objectList).stream().map(r -> r.object);
}

代码示例来源:origin: at.bestsolution.eclipse/org.eclipse.fx.core

/**
 * @return all ranked objects
 */
public synchronized List<T> getRankedElements() {
  return this.objectList.stream().map(r -> r.object).collect(Collectors.toList());
}

代码示例来源:origin: visallo/vertexium

private List<Mutation> getFilteredMutations(Predicate<Mutation> filter) {
  mutationLock.readLock().lock();
  try {
    return this.mutations.stream()
        .filter(filter)
        .collect(Collectors.toList());
  } finally {
    mutationLock.readLock().unlock();
  }
}

代码示例来源:origin: yahoo/fili

@Override
public TreeSet<DimensionRow> inFilterOperation(TreeSet<DimensionRow> dimensionRows, ApiFilter filter) {
  return dimensionRows.stream()
      .filter(row -> filter.getValues().contains(row.get(filter.getDimensionField())))
      .collect(Collectors.toCollection(TreeSet<DimensionRow>::new));
}

代码示例来源:origin: com.android.tools.build/builder

@Override
public String toString() {
  StringJoiner j = new StringJoiner(", ");
  mMap.stream()
      .map(e -> e.getStart() + " - " + e.getEnd() + ": " + e.getStore())
      .forEach(j::add);
  return "FileUseMap[" + j.toString() + "]";
}

代码示例来源:origin: visallo/vertexium

public Iterable<ExtendedDataRow> getRows(VisibilityEvaluator visibilityEvaluator) {
  return rows.stream()
      .map(row -> row.toReadable(visibilityEvaluator))
      .filter(row -> IterableUtils.count(row.getProperties()) > 0)
      .collect(Collectors.toList());
}

代码示例来源:origin: org.geoserver.community/gs-wfs3

private String getGeoServerVersion() {
    ManifestLoader.AboutModel versions = ManifestLoader.getVersions();
    TreeSet<ManifestLoader.AboutModel.ManifestModel> manifests = versions.getManifests();
    return manifests
        .stream()
        .filter(m -> m.getName().equalsIgnoreCase("GeoServer"))
        .map(m -> m.getEntries().get("Version"))
        .findFirst()
        .orElse("1.0.0");
  }
}

代码示例来源:origin: io.permazen/permazen-coreapi

private int write(XMLStreamWriter writer, boolean nameFormat) throws XMLStreamException {
  // Gather all known object storage IDs
  final TreeSet<Integer> storageIds = new TreeSet<>();
  for (Schema schema : this.tx.getSchemas().getVersions().values())
    storageIds.addAll(schema.getSchemaModel().getSchemaObjectTypes().keySet());
  // Get corresponding object sets
  final ArrayList<NavigableSet<ObjId>> sets = storageIds.stream()
   .map(this.tx::getAll)
   .collect(Collectors.toCollection(() -> new ArrayList<>(storageIds.size())));
  // Output all objects
  return this.write(writer, nameFormat, Iterables.concat(sets));
}

代码示例来源:origin: org.jsimpledb/jsimpledb-coreapi

private int write(XMLStreamWriter writer, boolean nameFormat) throws XMLStreamException {
  // Gather all known object storage IDs
  final TreeSet<Integer> storageIds = new TreeSet<>();
  for (Schema schema : this.tx.getSchemas().getVersions().values())
    storageIds.addAll(schema.getSchemaModel().getSchemaObjectTypes().keySet());
  // Get corresponding object sets
  final ArrayList<NavigableSet<ObjId>> sets = storageIds.stream()
   .map(this.tx::getAll)
   .collect(Collectors.toCollection(() -> new ArrayList<>(storageIds.size())));
  // Output all objects
  return this.write(writer, nameFormat, Iterables.concat(sets));
}

代码示例来源:origin: otros-systems/otroslogviewer

private void reloadThreads() {
 LogData[] ld = collector.getLogData();
 TreeSet<String> sortedThreads = new TreeSet<>(String::compareToIgnoreCase);
 for (LogData logData : ld) {
  sortedThreads.add(logData.getThread());
 }
 sortedThreads.stream()
  .filter(sortedThread -> !listModel.contains(sortedThread))
  .forEach(sortedThread -> listModel.add(listModel.getSize(), sortedThread));
 setThreadToFilter(selectedThread.toArray(new String[selectedThread.size()]));
}

代码示例来源:origin: com.facebook.presto/presto-tpch

public Optional<Long> getDataSize()
  {
    if (type.getBase() == TpchColumnType.Base.VARCHAR) {
      return Optional.of(nonNullValues.stream()
          .map(String.class::cast)
          .mapToLong(String::length)
          .sum());
    }
    return Optional.empty();
  }
}

代码示例来源:origin: otros-systems/otroslogviewer

@Test
public void testPreparePackagesNodes() throws Exception {
 //given
 final HashSet<String> clazzes = new HashSet<>(Arrays.asList("a.b.C", "a.b.D", "c.d.A", "A"));
 //when
 final TreeSet<String> packages = filter.preparePackagesNodes(clazzes);
 //then
 assertEquals(packages.size(), 4);
 assertEquals(packages, new HashSet<>(Arrays.asList("a", "a.b", "c", "c.d")));
 packages.stream().forEach(System.out::println);
}

代码示例来源:origin: RS485/LogisticsPipes

public static void refreshFluid(EntityPlayer player, CoreRoutedPipe pipe) {
  TreeSet<FluidIdentifierStack> _allItems = SimpleServiceLocator.logisticsFluidManager.getAvailableFluid(pipe.getRouter().getIRoutersByCost());
  MainProxy.sendPacketToPlayer(PacketHandler.getPacket(OrdererContent.class)
          .setIdentSet(
              _allItems.stream()
                  .map(item -> new ItemIdentifierStack(item.getFluid().getItemIdentifier(), item.getAmount()))
                  .collect(Collectors.toCollection(TreeSet::new))
          )
      , player);
}

相关文章