タグ

2014年12月28日のブックマーク (2件)

  • Java Streamメモ(Hishidama's Java8 Stream Memo)

    概要 Stream系クラス Stream系メソッド Stream生成 [/2018-10-01] メソッド Stream [/2021-03-21] BaseStream プリミティブStream [/2021-03-21] onClose [2015-12-13] Streamの例 [/2021-03-21] 概要 JDK1.8で導入されたStreamは、複数の値(オブジェクト)に対して何らかの処理(変換や集計)を行う事を分かりやすく記述できる。 import java.util.stream.Stream; Streamの値の持ち方はjava.util.Listのようなイメージ。 しかしStreamの操作は一度しか行えないので(ScalaのTraversableOnce相当)、java.util.Iteratorの方が近いかも。 つまり複数の値を保持し、順次処理していく。 なお、Str

    msykt
    msykt 2014/12/28
    これに気がつくまで時間かかった。分かりにくい…/“Stream<Integer>とIntStreamは意味的には同じかもしれないが、用意されているメソッドやintに対する処理速度は異なる。”
  • Does Java SE 8 have Pairs or Tuples?

    I am playing around with lazy functional operations in Java SE 8, and I want to map an index i to a pair / tuple (i, value[i]), then filter based on the second value[i] element, and finally output just the indices. Must I still suffer this: What is the equivalent of the C++ Pair<L,R> in Java? in the bold new era of lambdas and streams? Update: I presented a rather simplified example, which has a n

    Does Java SE 8 have Pairs or Tuples?
    msykt
    msykt 2014/12/28
    JavaにPairやTupleがない件。標準クラスライブラリに入れない、というのは賛成。でもStream APIを使う時にはやっぱり欲しい。利用できるケースを限定するようなことができれば良いんだろうな。