Java Code Examples for java.util.stream.IntStream#concat()
The following examples show how to use
java.util.stream.IntStream#concat() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: rapidminer-studio File: MassiveDataGenerator.java License: GNU Affero General Public License v3.0 | 6 votes |
@Override public MetaData getGeneratedMetaData() throws OperatorException { ExampleSetMetaData emd = new ExampleSetMetaData(); emd.addAttribute(new AttributeMetaData("label", Ontology.NOMINAL, Attributes.LABEL_NAME)); emd.setNumberOfExamples(getParameterAsInt(PARAMETER_NUMBER_EXAMPLES)); int desiredNumberOfAttributes = getParameterAsInt(PARAMETER_NUMBER_ATTRIBUTES); double mean = getParameterAsDouble(PARAMETER_SPARSE_FRACTION); IntStream attributeIndices; if (desiredNumberOfAttributes <= MAX_METADATA_ATTRIBUTES) { // all attributes attributeIndices = IntStream.range(1, desiredNumberOfAttributes); } else { // first ten and last ten attributeIndices = IntStream.concat(IntStream.rangeClosed(1, MAX_METADATA_ATTRIBUTES/2), IntStream.rangeClosed(desiredNumberOfAttributes - MAX_METADATA_ATTRIBUTES/2 + 1, desiredNumberOfAttributes)); } attributeIndices.mapToObj(i -> new AttributeMetaData("att" + i, null, Ontology.REAL, new Range(0, 1))) .peek(amd -> amd.setMean(new MDReal(mean))).forEach(emd::addAttribute); return emd; }
Example 2
Source Project: dragonwell8_jdk File: ConcatTest.java License: GNU General Public License v2.0 | 5 votes |
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) { IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue)); assertEquals(result.isParallel(), parallel); assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator()); }
Example 3
Source Project: TencentKona-8 File: ConcatTest.java License: GNU General Public License v2.0 | 5 votes |
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) { IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue)); assertEquals(result.isParallel(), parallel); assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator()); }
Example 4
Source Project: jdk8u60 File: ConcatTest.java License: GNU General Public License v2.0 | 5 votes |
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) { IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue)); assertEquals(result.isParallel(), parallel); assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator()); }
Example 5
Source Project: teku File: Utils.java License: Apache License 2.0 | 5 votes |
private static List<ByteBuf> shiftedSlices(int shift, Bytes... chunks) { AtomicInteger sum = new AtomicInteger(0); IntStream pos = IntStream.concat( IntStream.of(0), Arrays.stream(chunks).mapToInt(Bytes::size).map(sum::addAndGet)); if (shift > 0) { pos = pos.limit(chunks.length); } else { pos = pos.skip(1); } pos = pos.map(p -> p + shift).map(p -> Math.max(p, 0)); return slice(toByteBuf(chunks), pos.toArray()); }
Example 6
Source Project: openjdk-jdk8u File: ConcatTest.java License: GNU General Public License v2.0 | 5 votes |
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) { IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue)); assertEquals(result.isParallel(), parallel); assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator()); }
Example 7
Source Project: openjdk-jdk8u-backup File: ConcatTest.java License: GNU General Public License v2.0 | 5 votes |
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) { IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue)); assertEquals(result.isParallel(), parallel); assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator()); }
Example 8
Source Project: openjdk-jdk9 File: ConcatTest.java License: GNU General Public License v2.0 | 5 votes |
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) { IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue)); assertEquals(result.isParallel(), parallel); assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator()); }
Example 9
Source Project: jdk8u-jdk File: ConcatTest.java License: GNU General Public License v2.0 | 5 votes |
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) { IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue)); assertEquals(result.isParallel(), parallel); assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator()); }
Example 10
Source Project: hottub File: ConcatTest.java License: GNU General Public License v2.0 | 5 votes |
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) { IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue)); assertEquals(result.isParallel(), parallel); assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator()); }
Example 11
Source Project: openjdk-8-source File: ConcatTest.java License: GNU General Public License v2.0 | 5 votes |
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) { IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue)); assertEquals(result.isParallel(), parallel); assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator()); }
Example 12
Source Project: openjdk-8 File: ConcatTest.java License: GNU General Public License v2.0 | 5 votes |
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) { IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue)); assertEquals(result.isParallel(), parallel); assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator()); }
Example 13
Source Project: jdk8u_jdk File: ConcatTest.java License: GNU General Public License v2.0 | 5 votes |
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) { IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue)); assertEquals(result.isParallel(), parallel); assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator()); }
Example 14
Source Project: jdk8u-dev-jdk File: ConcatTest.java License: GNU General Public License v2.0 | 5 votes |
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) { IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue)); assertEquals(result.isParallel(), parallel); assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator()); }
Example 15
Source Project: jdk8u-jdk File: ConcatTest.java License: GNU General Public License v2.0 | 5 votes |
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) { IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue)); assertEquals(result.isParallel(), parallel); assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator()); }
Example 16
Source Project: TweetwallFX File: Tweet.java License: MIT License | 5 votes |
public String get() { if (entriesToRemove.isEmpty()) { return tweet.getText(); } IntStream filteredIndexes = IntStream.empty(); for (TweetEntry tweetEntry : entriesToRemove) { final IntStream nextFilter; if (tweetEntry.getStart() == tweetEntry.getEnd()) { nextFilter = IntStream.of(tweetEntry.getStart()); } else { nextFilter = IntStream.range(tweetEntry.getStart(), tweetEntry.getEnd()); } filteredIndexes = IntStream.concat(filteredIndexes, nextFilter); } final Set<Integer> indexesToFilterOut = filteredIndexes.boxed().collect(toCollection(TreeSet::new)); final int[] chars = tweet.getText().chars().toArray(); final int[] filteredChars = IntStream.range(0, chars.length) .filter(i -> !indexesToFilterOut.contains(i)) .map(i -> chars[i]) .toArray(); return new String(filteredChars, 0, filteredChars.length) .replaceAll(" *", " ") .trim(); }
Example 17
Source Project: levelup-java-examples File: IntStreamExample.java License: Apache License 2.0 | 3 votes |
@Test public void intstream_concat() { IntStream first = IntStream.builder().add(10).build(); IntStream second = IntStream.builder().add(10).build(); IntStream third = IntStream.concat(first, second); assertEquals(20, third.sum()); }
Example 18
Source Project: streamex File: IntStreamEx.java License: Apache License 2.0 | 2 votes |
/** * Returns a new {@code IntStreamEx} which is a concatenation of this stream * and the stream containing supplied values * * <p> * This is a <a href="package-summary.html#StreamOps">quasi-intermediate * operation</a>. * * @param values the values to append to the stream * @return the new stream */ public IntStreamEx append(int... values) { if (values.length == 0) return this; return new IntStreamEx(IntStream.concat(stream(), IntStream.of(values)), context); }
Example 19
Source Project: streamex File: IntStreamEx.java License: Apache License 2.0 | 2 votes |
/** * Creates a lazily concatenated stream whose elements are all the elements * of this stream followed by all the elements of the other stream. The * resulting stream is ordered if both of the input streams are ordered, and * parallel if either of the input streams is parallel. When the resulting * stream is closed, the close handlers for both input streams are invoked. * * @param other the other stream * @return this stream appended by the other stream * @see IntStream#concat(IntStream, IntStream) */ public IntStreamEx append(IntStream other) { return new IntStreamEx(IntStream.concat(stream(), other), context.combine(other)); }
Example 20
Source Project: streamex File: IntStreamEx.java License: Apache License 2.0 | 2 votes |
/** * Returns a new {@code IntStreamEx} which is a concatenation of the stream * containing supplied values and this stream * * <p> * This is a <a href="package-summary.html#StreamOps">quasi-intermediate * operation</a>. * * @param values the values to prepend to the stream * @return the new stream */ public IntStreamEx prepend(int... values) { if (values.length == 0) return this; return new IntStreamEx(IntStream.concat(IntStream.of(values), stream()), context); }