<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                # Stream 接口一覽 <br> ## List 轉 Stream ``` // 轉stream list.stream() // 并發處理 list.parallelStream() ``` ## filter(過濾) ``` Stream<T> filter(Predicate<? super T> predicate); ``` <br> ## map(元素轉換) ``` <R> Stream<R> map(Function<? super T, ? extends R> mapper); IntStream mapToInt(ToIntFunction<? super T> mapper); LongStream mapToLong(ToLongFunction<? super T> mapper); DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper); ``` <br> ## flatMap(元素轉換) ``` <R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper); IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper); LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper); DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper); ``` <br> ## distinct(去除重復,對象需要重寫 equals、hashCode) ``` Stream<T> distinct(); ``` <br> ## sorted(排序) ``` Stream<T> sorted(); Stream<T> sorted(Comparator<? super T> comparator); ``` <br> ## peek(生成新的流:流是單向的,例如用于日志打印) ``` Stream<T> peek(Consumer<? super T> action); ``` <br> ## limit(取前面 `n` 個元素) ``` Stream<T> limit(long maxSize); ``` <br> ## skip(跳過 `n` 個元素) ``` Stream<T> skip(long n); ``` <br> ## forEach(遍歷) ``` void forEach(Consumer<? super T> action); void forEachOrdered(Consumer<? super T> action); ``` <br> ## toArray(轉換成數組) ``` Object[] toArray(); <A> A[] toArray(IntFunction<A[]> generator); ``` <br> ## reduce(結果歸并) ``` T reduce(T identity, BinaryOperator<T> accumulator); Optional<T> reduce(BinaryOperator<T> accumulator); <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner); ``` <br> ## collect(轉換成集合) ``` <R> R collect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner); <R, A> R collect(Collector<? super T, A, R> collector); ``` <br> ## 轉list ``` // 轉list Collectors.toList(); // 轉set Collectors.toSet(); // 轉map List<TestVo> testList = new ArrayList<>(10); Map<Long, TestVo> data = releaseList.stream() .collect(Collectors.toMap(TestVo::getId, x -> x)); ``` <br> ## count(計數) ``` long count(); ``` <br> ## 查找 ``` boolean anyMatch(Predicate<? super T> predicate); boolean allMatch(Predicate<? super T> predicate); boolean noneMatch(Predicate<? super T> predicate); ``` <br> ## 查找 ``` Optional<T> findFirst(); Optional<T> findAny(); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看