Example usage for java.util.stream IntStream rangeClosed

List of usage examples for java.util.stream IntStream rangeClosed

Introduction

In this page you can find the example usage for java.util.stream IntStream rangeClosed.

Prototype

public static IntStream rangeClosed(int startInclusive, int endInclusive) 

Source Link

Document

Returns a sequential ordered IntStream from startInclusive (inclusive) to endInclusive (inclusive) by an incremental step of 1 .

Usage

From source file:Main.java

public static void main(String[] args) {
    IntStream.rangeClosed(1, 5).map(n -> n * n).forEach(System.out::println);

}

From source file:Main.java

public static void main(String[] argv) {
    IntStream.rangeClosed(1, 10).forEach(num -> System.out.println(num));

    System.out.println("");

    IntStream.range(1, 10).forEach(num -> System.out.println(num));
}

From source file:Main.java

public static void main(String[] args) {
    IntStream i = IntStream.rangeClosed(1, 7);
    i.forEach(System.out::println);

}

From source file:Main.java

public static void main(String[] args) {
    IntStream i = IntStream.rangeClosed(1, 7);
    i.peek(System.out::println);

}

From source file:beyondlambdas.slides.s8_1.Support.java

public static Stream<String> jsonData() {
    return IntStream.rangeClosed(1, 20).mapToObj(Support::item);
}

From source file:Main.java

/**
 * Split the list and return the stream with the resultant lists.
 *
 * @param list to be split//  w  ww .ja v  a2 s.  co  m
 * @param size of each list after splitting.
 * @param <T>  type of list.
 * @return {@link Stream} of {@link List}s
 */
public static <T> Stream<List<T>> splitListStream(final List<T> list, final int size) {

    if (size <= 0) {
        throw new IllegalArgumentException("Invalid Split Size");
    }

    final int listSize = list.size();

    if (listSize == 0) {
        return Stream.empty();
    }

    return IntStream.rangeClosed(0, (listSize - 1) / size)
            .mapToObj(n -> list.subList(n * size, Math.min((n + 1) * size, listSize)));
}

From source file:org.kordamp.javatrove.example02.TestHelper.java

public static List<Repository> createSampleRepositories() {
    return IntStream.rangeClosed(1, 10)
            .mapToObj(i -> Repository.builder().name("repo" + i).fullName("foo/repo" + i).build())
            .collect(toList());//from  w  ww  . j av a 2 s.  c  o  m
}

From source file:beyondlambdas.slides.s8_1.Support.java

public static Stream<String> badJsonData() {
    final List<Integer> integers = IntStream.rangeClosed(1, 20).boxed().collect(toList());
    integers.set(12, 21);//from w ww.  jav  a 2 s .  co  m
    return integers.stream().map(Support::item);
}

From source file:com.rationaldevelopers.oss.service.QueueService.java

@PostConstruct
public void initializeData() {
    IntStream.rangeClosed(1, 10).forEach(i -> addSimpleItem(new SimpleItem("Name " + i, "Description : " + i)));
}

From source file:com.abosancic.activemq.service.MessageService.java

public void sendMessages(Integer num) {
    // Send messages
    IntStream.rangeClosed(1, num).forEach(index -> {
        sendMessage(index);
    });
}