以下の内容はhttps://unageanu.hatenablog.com/entry/20090922/1253625809より取得しました。


find

なんだ、findはあるのか。 > Google Collections

import static com.google.common.collect.Iterables.*;
import static com.google.common.collect.Sets.*;
import static com.google.common.base.Predicates.*;
...
// セット
Set<String> set = newHashSet("aaa", "bbb", "ccc"); 

// "bbb"を探す。
String str = find(set, equalTo("bbb"));
System.out.println( str );

実行結果です。

bbb

よくみるとtransformとしてmapみたいな機能の関数もありますねー。

import static com.google.common.collect.Sets.*;
import static com.google.common.collect.Collections2.*;
...
// 要素をIntegerに変換
Set<String> set = newHashSet("10", "20", "30"); 
Collection<Integer> converted = transform(set, new Function<String,Integer>() {
    @Override public Integer apply(String arg) {
        return Integer.valueOf(arg);
    }
});
System.out.println( converted );

実行結果です。

[20, 10, 30]



以上の内容はhttps://unageanu.hatenablog.com/entry/20090922/1253625809より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14