本文整理了Java中java.util.TreeSet.forEach()
方法的一些代码示例,展示了TreeSet.forEach()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeSet.forEach()
方法的具体详情如下:
包路径:java.util.TreeSet
类名称:TreeSet
方法名:forEach
暂无
代码示例来源:origin: SonarSource/sonarqube
private void writeEnvVariables(BufferedWriter fileWriter) throws IOException {
fileWriter.append("Environment variables:\n");
Map<String, String> envVariables = system.envVariables();
new TreeSet<>(envVariables.keySet())
.forEach(envKey -> {
try {
String envValue = isSensitiveEnvVariable(envKey) ? "******" : envVariables.get(envKey);
fileWriter.append(String.format(KEY_VALUE_FORMAT, envKey, envValue)).append('\n');
} catch (IOException e) {
throw new IllegalStateException(e);
}
});
}
代码示例来源:origin: sixt/ja-micro
handlerNamesSorted.forEach(key -> {
StringBuilder sb = new StringBuilder();
sb.append("{\"name\":\"");
代码示例来源:origin: org.leapframework/leap-webunit
@Override
public List<okhttp3.Cookie> loadForRequest(HttpUrl url) {
List<okhttp3.Cookie> cookies = new ArrayList<>();
store.forEach(c -> cookies.add(((CookieImpl)c).cookie));
return cookies;
}
}
代码示例来源:origin: org.apache.beam/beam-sdks-java-core
@Override
public LargestUnique mergeAccumulators(Iterable<LargestUnique> heaps) {
Iterator<LargestUnique> iterator = heaps.iterator();
LargestUnique accumulator = iterator.next();
while (iterator.hasNext()) {
iterator.next().heap.forEach(h -> accumulator.add(h));
}
return accumulator;
}
代码示例来源:origin: com.simiacryptus/mindseye
@Override
public synchronized void reset() {
history.forEach(x -> x.freeRef());
history.clear();
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-scanner-engine
private void writeEnvVariables(BufferedWriter fileWriter) throws IOException {
fileWriter.append("Environment variables:\n");
Map<String, String> envVariables = system.envVariables();
new TreeSet<>(envVariables.keySet())
.forEach(envKey -> {
try {
String envValue = isSensitiveEnvVariable(envKey) ? "******" : envVariables.get(envKey);
fileWriter.append(String.format(KEY_VALUE_FORMAT, envKey, envValue)).append('\n');
} catch (IOException e) {
throw new IllegalStateException(e);
}
});
}
代码示例来源:origin: com.simiacryptus/mindseye
private LBFGS setHistory(@Nonnull final TrainingMonitor monitor, @Nonnull final List<PointSample> history) {
if (history.size() == this.history.size() && history.stream().filter(x -> !this.history.contains(x)).count() == 0)
return this;
if (verbose) {
monitor.log(String.format("Overwriting history with %s points", history.size()));
}
synchronized (this.history) {
history.forEach(x -> x.addRef());
this.history.forEach(x -> x.freeRef());
this.history.clear();
this.history.addAll(history);
}
return this;
}
代码示例来源:origin: gradle.plugin.com.s390x/gogradle
@Override
public GolangDependencySet clone() {
try {
GolangDependencySet ret = (GolangDependencySet) super.clone();
ret.container = new TreeSet<>(
comparing((Serializable & Function<GolangDependency, String>) GolangDependency::getName));
this.container.forEach(item -> ret.add((GolangDependency) item.clone()));
return ret;
} catch (CloneNotSupportedException e) {
return null;
}
}
}
代码示例来源:origin: osmlab/atlas
@Override
protected int finish(final CommandMap command)
{
@SuppressWarnings("unchecked")
final Optional<File> possibleFile = (Optional<File>) command.getOption(OUTPUT_PARAMETER);
if (possibleFile.isPresent())
{
try (PrintStream out = new PrintStream(
new FileOutputStream(possibleFile.get().getFile(), true)))
{
this.restrictedPaths.forEach(value -> out.println(value));
}
catch (final IOException oops)
{
throw new CoreException("Error writing restrictedPaths to file", oops);
}
}
else
{
try (PrintStream out = new PrintStream(System.out))
{
this.restrictedPaths.forEach(value -> out.println(value));
}
}
return 0;
}
代码示例来源:origin: osmlab/atlas
@Override
protected int finish(final CommandMap command)
{
final File file = (File) command.get(OUTPUT_PARAMETER);
try (PrintStream out = new PrintStream(new FileOutputStream(file.getFile(), true)))
{
this.turnRestrictions.forEach(value -> out.println(value));
}
catch (final IOException oops)
{
throw new CoreException("Error writing turnRestriction ids to file", oops);
}
return 0;
}
代码示例来源:origin: org.uberfire/uberfire-experimental-client
@OnOpen
public void show() {
clear();
ExperimentalFeaturesRegistry registry = registryService.getFeaturesRegistry();
if (registry != null) {
Map<String, Set<ExperimentalFeature>> groupedFeatures = registry.getAllFeatures().stream()
.collect(Collectors.groupingBy(this::getFeatureGroupName, Collectors.toSet()));
TreeSet<ExperimentalFeaturesGroup> groups = groupedFeatures.entrySet()
.stream()
.map(this::getFeaturesGroup)
.filter(Objects::nonNull)
.collect(Collectors.toCollection(TreeSet::new));
if (!groups.isEmpty()) {
groups.first().expand();
groups.forEach(view::add);
}
}
}
代码示例来源:origin: kiegroup/appformer
@OnOpen
public void show() {
clear();
ExperimentalFeaturesRegistry registry = registryService.getFeaturesRegistry();
if (registry != null) {
Map<String, Set<ExperimentalFeature>> groupedFeatures = registry.getAllFeatures().stream()
.collect(Collectors.groupingBy(this::getFeatureGroupName, Collectors.toSet()));
TreeSet<ExperimentalFeaturesGroup> groups = groupedFeatures.entrySet()
.stream()
.map(this::getFeaturesGroup)
.filter(Objects::nonNull)
.collect(Collectors.toCollection(TreeSet::new));
if (!groups.isEmpty()) {
groups.first().expand();
groups.forEach(view::add);
}
}
}
代码示例来源:origin: T145/JTerm
@Command(name = "help")
public static void printHelp(List<String> options) {
JTerm.out.println(TextColor.INFO, "JTerm v" + JTerm.VERSION + "\n"
+ "Available Commands\n"
+ "(type [command] -h to view specific help information)");
new TreeSet<>(JTerm.getCommands()).forEach(command -> JTerm.out.printf(TextColor.INFO, "\t%s%n", command));
}
}
代码示例来源:origin: platonai/pulsar
@Test
public void testTreeSet() {
TreeSet<Integer> integers = IntStream.range(0, 30).boxed().collect(TreeSet::new, TreeSet::add, TreeSet::addAll);
integers.forEach(System.out::print);
integers.pollLast();
System.out.println();
integers.forEach(System.out::print);
}
代码示例来源:origin: hypercube1024/firefly
@Override
public boolean verifyEchoString(EchoRequest request) {
Assert.hasText(request.getEchostr(), "The echo string must be not empty");
Assert.hasText(request.getSignature(), "The signature string must be not empty");
Assert.hasText(request.getNonce(), "The nonce string must be not empty");
Assert.notNull(request.getTimestamp(), "The timestamp must be not null");
Assert.isTrue(request.getTimestamp() > 0, "The timestamp string must be greater than 0");
TreeSet<String> set = new TreeSet<>(Arrays.asList(request.getNonce(), request.getTimestamp().toString(), wechatToken));
StringBuilder sign = new StringBuilder();
set.forEach(sign::append);
try {
String originSign = sign.toString();
String hexSign = HexUtils.bytesToHex(MessageDigest.getInstance("SHA-1").digest(originSign.getBytes(StandardCharsets.US_ASCII)));
log.info("verify echo string. {} | {} | {}", originSign, hexSign, request.getSignature());
return request.getSignature().equals(hexSign);
} catch (Exception e) {
log.error("verify echo string exception", e);
return false;
}
}
代码示例来源:origin: org.uberfire/uberfire-experimental-client
public void init(final String labelKey, final Collection<ExperimentalFeature> features, final ParameterizedCommand<EditableExperimentalFeature> callback) {
PortablePreconditions.checkNotNull("labelKey", labelKey);
PortablePreconditions.checkNotNull("features", features);
PortablePreconditions.checkNotNull("callback", callback);
clear();
this.labelKey = labelKey;
this.callback = feature -> {
callback.execute(feature);
setEnableAllLabel();
};
view.setLabel(getLabel());
features.stream()
.map(this::getEditor)
.collect(Collectors.toCollection(TreeSet::new))
.forEach(view::render);
setEnableAllLabel();
}
代码示例来源:origin: kiegroup/appformer
public void init(final String labelKey, final Collection<ExperimentalFeature> features, final ParameterizedCommand<EditableExperimentalFeature> callback) {
PortablePreconditions.checkNotNull("labelKey", labelKey);
PortablePreconditions.checkNotNull("features", features);
PortablePreconditions.checkNotNull("callback", callback);
clear();
this.labelKey = labelKey;
this.callback = feature -> {
callback.execute(feature);
setEnableAllLabel();
};
view.setLabel(getLabel());
features.stream()
.map(this::getEditor)
.collect(Collectors.toCollection(TreeSet::new))
.forEach(view::render);
setEnableAllLabel();
}
代码示例来源:origin: org.kie.workbench/kie-wb-common-dmn-client
@SuppressWarnings("unused")
void onNestedElementAdded(final @Observes ExpressionEditorChanged event) {
final Node node = presenter.getGraph().getNode(getActiveParent().getUUID());
presenter.updateElement(node);
getActiveParent().getChildren().forEach(e -> getTreePresenter().selectItem(e.getUUID()));
}
代码示例来源:origin: broadinstitute/picard
private void writeAllViolations(final MendelianViolationDetector.Result result) {
if (VCF_DIR != null) {
LOG.info(String.format("Writing family violation VCFs to %s/", VCF_DIR.getAbsolutePath()));
final VariantContextComparator vcComparator = new VariantContextComparator(inputHeader.get().getContigLines());
final Set<VCFHeaderLine> headerLines = new LinkedHashSet<>(inputHeader.get().getMetaDataInInputOrder());
headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.MENDELIAN_VIOLATION_KEY, 1, VCFHeaderLineType.String, "Type of mendelian violation."));
headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AC, VCFHeaderLineCount.A, VCFHeaderLineType.Integer, "Original AC"));
headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AF, VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Original AF"));
headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AN, 1, VCFHeaderLineType.Integer, "Original AN"));
for (final PedFile.PedTrio trio : pedFile.get().values()) {
final File outputFile = new File(VCF_DIR, IOUtil.makeFileNameSafe(trio.getFamilyId() + IOUtil.VCF_FILE_EXTENSION));
LOG.info(String.format("Writing %s violation VCF to %s", trio.getFamilyId(), outputFile.getAbsolutePath()));
final VariantContextWriter out = new VariantContextWriterBuilder()
.setOutputFile(outputFile)
.unsetOption(INDEX_ON_THE_FLY)
.build();
final VCFHeader newHeader = new VCFHeader(headerLines, CollectionUtil.makeList(trio.getMaternalId(), trio.getPaternalId(), trio.getIndividualId()));
final TreeSet<VariantContext> orderedViolations = new TreeSet<>(vcComparator);
orderedViolations.addAll(result.violations().get(trio.getFamilyId()));
out.writeHeader(newHeader);
orderedViolations.forEach(out::add);
out.close();
}
}
}
代码示例来源:origin: com.github.broadinstitute/picard
private void writeAllViolations(final MendelianViolationDetector.Result result) {
if (VCF_DIR != null) {
LOG.info(String.format("Writing family violation VCFs to %s/", VCF_DIR.getAbsolutePath()));
final VariantContextComparator vcComparator = new VariantContextComparator(inputHeader.get().getContigLines());
final Set<VCFHeaderLine> headerLines = new LinkedHashSet<>(inputHeader.get().getMetaDataInInputOrder());
headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.MENDELIAN_VIOLATION_KEY, 1, VCFHeaderLineType.String, "Type of mendelian violation."));
headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AC, VCFHeaderLineCount.A, VCFHeaderLineType.Integer, "Original AC"));
headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AF, VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Original AF"));
headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AN, 1, VCFHeaderLineType.Integer, "Original AN"));
for (final PedFile.PedTrio trio : pedFile.get().values()) {
final File outputFile = new File(VCF_DIR, IOUtil.makeFileNameSafe(trio.getFamilyId() + IOUtil.VCF_FILE_EXTENSION));
LOG.info(String.format("Writing %s violation VCF to %s", trio.getFamilyId(), outputFile.getAbsolutePath()));
final VariantContextWriter out = new VariantContextWriterBuilder()
.setOutputFile(outputFile)
.unsetOption(INDEX_ON_THE_FLY)
.build();
final VCFHeader newHeader = new VCFHeader(headerLines, CollectionUtil.makeList(trio.getMaternalId(), trio.getPaternalId(), trio.getIndividualId()));
final TreeSet<VariantContext> orderedViolations = new TreeSet<>(vcComparator);
orderedViolations.addAll(result.violations().get(trio.getFamilyId()));
out.writeHeader(newHeader);
orderedViolations.forEach(out::add);
out.close();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!