﻿{"id":690,"date":"2013-04-07T04:50:57","date_gmt":"2013-04-06T19:50:57","guid":{"rendered":"http:\/\/yucchi.jp\/blog\/?p=690"},"modified":"2013-04-24T19:49:25","modified_gmt":"2013-04-24T10:49:25","slug":"jdk8-lambda-%e3%81%9d%e3%81%ae%e4%bb%96%e3%81%84%e3%82%8d%e3%81%84%e3%82%8d-%e3%81%aa%e3%82%93%e3%81%a7%e3%82%82%e3%81%84%e3%81%84%e3%81%8b%e3%82%89%e5%8b%95%e3%81%8b%e3%81%97%e3%81%a6%e3%81%bf-5","status":"publish","type":"post","link":"http:\/\/yucchi.jp\/blog\/?p=690","title":{"rendered":"JDK8 Lambda \u305d\u306e\u4ed6\u3044\u308d\u3044\u308d \u306a\u3093\u3067\u3082\u3044\u3044\u304b\u3089\u52d5\u304b\u3057\u3066\u307f\u308b \u305d\u306e\uff16"},"content":{"rendered":"<style type=\"text\/css\">\n<!--\ntable {color: #000000; background-color: #e9e8e2; font-family: \u3086\u305f\u307d\u3093\uff08\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\uff09}\n-->\n<\/style>\n<p>JDK8 Lambda \u305d\u306e\u4ed6\u3044\u308d\u3044\u308d \u306a\u3093\u3067\u3082\u3044\u3044\u304b\u3089\u52d5\u304b\u3057\u3066\u307f\u308b \u30b7\u30ea\u30fc\u30ba\u3082\uff16\u56de\u76ee\u3068\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u304b\u306a\u308a\u3057\u3064\u3053\u304f\u5f15\u3063\u5f35\u3063\u3066\u307e\u3059\u3002(\uffe3\u3002\uffe3;)<\/p>\n<p>\u6c17\u306b\u305b\u305a\u4eca\u65e5\u306f \u5973\u6027\u540c\u58eb\u306b\u3088\u308b\u58f2\u8cb7\u306e\u5408\u8a08\u91d1\u984d \u3092\u8a08\u7b97\u3055\u305b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u5973\u6027\u306e\u58f2\u308a\u624b\u3068\u8cb7\u3044\u624b\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3066\u58f2\u308a\u5024\u306e\u5408\u8a08\u3092\u8a08\u7b97\u3059\u308c\u3070\u3088\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n<table width=\"100%\">\n<tbody>\n<tr>\n<td align=\"left\">mylambdaexamples\\MyLambdaExamples.java<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre start-line=\"77\">\r\n\/\/ \u5973\u6027\u540c\u58eb\u306b\u3088\u308b\u58f2\u8cb7\u306e\u5408\u8a08\u91d1\u984d\r\nSystem.out.println(\"\\n<-- \u5973\u6027\u540c\u58eb\u306b\u3088\u308b\u58f2\u8cb7\u306e\u5408\u8a08\u91d1\u984d -->\");\r\ndouble sum = sales.filter(s -> s.getBuyer().getGender() == Person.Sex.FEMALE\r\n        && s.getSeller().getGender() == Person.Sex.FEMALE)\r\n        .mapToDouble(Sale::getCost)\r\n        .sum();\r\nSystem.out.println((int) sum + \"\u5186\");\r\n<\/pre>\n<p>\u4eca\u56de\u3082\u898b\u6163\u308c\u306a\u3044\u3082\u306e\u304c\u30fb\u30fb\u30fb<\/p>\n<p>mapToDouble() , sum() \u3053\u308c\u3089\u306f\u30e1\u30bd\u30c3\u30c9\u540d\u3068\u30b3\u30fc\u30c9\u304b\u3089\u3069\u3046\u3044\u3063\u305f\u3082\u306e\u304b\u3060\u3044\u305f\u3044\u306e\u60f3\u50cf\u306f\u3064\u304d\u307e\u3059\u306d\u3002<\/p>\n<p>\u3044\u3061\u304a\u3046 JavaDoc \u3092\u307f\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><font color=\"#ff0000\"><strong>mapToDouble()<\/strong><\/font><\/p>\n<p><b><a href=\"about:blank*0\" target=\"_blank\">java.\u200butil.\u200bstream.\u200bStream<\/a><\/b> <\/p>\n<p><tt>public <a href=\"about:blank*1\" target=\"_blank\">DoubleStream<\/a> <b>mapToDouble<\/b>(<a href=\"about:blank*2\" target=\"_blank\">ToDoubleFunction<\/a>&lt;? super T&gt; mapper)<\/tt> <\/p>\n<p>Produce a <code>DoubleStream<\/code> consisting of the results of applying the given function to the elements of this stream. <\/p>\n<p>This is an <a href=\"about:blankpackage-summary.html#StreamOps\" target=\"_blank\">intermediate operation<\/a>. <\/p>\n<p><b>\u30d1\u30e9\u30e1\u30fc\u30bf:<\/b> <\/p>\n<blockquote><p><code>mapper<\/code> &#8211; A <a href=\"about:blankpackage-summary.html#NonInterference\" target=\"_blank\">non-interfering, stateless<\/a> function to be applied to each element<\/p><\/blockquote>\n<p><b>\u623b\u308a\u5024:<\/b> <\/p>\n<blockquote>\n<p>the new stream <\/p>\n<\/blockquote>\n<p>\u3069\u3046\u3084\u3089 ToDoubleFunction \u306b\u3088\u3063\u3066 double \u578b\u306e\u65b0\u3057\u3044\u30b9\u30c8\u30ea\u30fc\u30e0\u3092\u3064\u304f\u308b\u3088\u3046\u3067\u3059\u3002\uff08\u305f\u3076\u3093\uff09<\/p>\n<p>&nbsp;<\/p>\n<p><font color=\"#ff0000\"><strong>sum()<\/strong><\/font><\/p>\n<p><b><a href=\"about:blank*0\" target=\"_blank\">java.\u200butil.\u200bstream.\u200bDoubleStream<\/a><\/b> <\/p>\n<p><tt>public double <b>sum<\/b>()<\/tt> <\/p>\n<p><tt><font face=\"\u30e1\u30a4\u30ea\u30aa\">\u3053\u308c\u3063\u3066\u30fb\u30fb\u30fb<\/font><\/tt> <\/p>\n<p><tt><font face=\"\u30e1\u30a4\u30ea\u30aa\">double \u578b\u306e\u5408\u8a08\u3063\u3066\u3053\u3068\u3060\u3088\u306d\u3002<\/font><\/tt> <\/p>\n<p><tt><font face=\"\u30e1\u30a4\u30ea\u30aa\">\u3053\u3093\u306a\u30b7\u30f3\u30d7\u30eb\u306a JavaDoc \u3063\u3066\u3042\u308a\u306a\u3093\u3060\u3002<\/font><\/tt> <\/p>\n<p><tt><font face=\"\u30e1\u30a4\u30ea\u30aa\">\u3055\u3066\u3001\u305d\u308c\u3067\u306f\u6c17\u306b\u306a\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u884c\u7d50\u679c\u3092\u307f\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><\/font><\/tt><\/p>\n<p>&lt;&#8211; \u5973\u6027\u540c\u58eb\u306b\u3088\u308b\u58f2\u8cb7\u306e\u5408\u8a08\u91d1\u984d &#8211;&gt;<br \/>3480000\u5186<\/p>\n<p><tt><\/tt><\/p>\n<p>\u3061\u3083\u3093\u3068\u3042\u3063\u3066\u308b\u304b\u78ba\u8a8d\u306f\u3057\u3066\u306a\u3044\u304c OK \u3068\u3057\u3088\u3046\uff01<\/p>\n<p>\u305d\u308c\u306b\u3057\u3066\u3082\u975e\u5e38\u306b\u30b7\u30f3\u30d7\u30eb\u3067\u826f\u3044\u3067\u3059\u306d\uff01<\/p>\n<p>\u3042\u3063\u3001\u304a\u7d04\u675f\u3092\u5fd8\u308c\u308b\u3068\u3053\u308d\u3067\u3057\u305f\u3002<\/p>\n<p>\u3067\u3082\u3001\u3053\u306e\u300cJDK8 Lambda \u305d\u306e\u4ed6\u3044\u308d\u3044\u308d \u306a\u3093\u3067\u3082\u3044\u3044\u304b\u3089\u52d5\u304b\u3057\u3066\u307f\u308b\u300d\u30b7\u30ea\u30fc\u30ba\u306f\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u4e0a\u3067\u5f97\u305f\u60c5\u5831\u3092\u5143\u306b\u305d\u308c\u3092\u5c11\u3057\u5909\u66f4\u3057\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<p>\u60b2\u3057\u3044\u3053\u3068\u306b\u305d\u306e\u60c5\u5831\u6e90\u306f\u82f1\u8a9e\u306a\u306e\u3067\u8a73\u3057\u3044\u5185\u5bb9\u306f\u308f\u304b\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u3088\u3063\u3066\u79c1\u306e\u63a8\u6e2c\u3067\u89e3\u91c8\u3055\u308c\u305f\u5185\u5bb9\u3068\u306a\u3063\u3066\u307e\u3059\u306e\u3067\u9593\u9055\u3044\u304c\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>Java8 \u3082\u307e\u3060 build83 \u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u306e\u3067 API \u306e\u5909\u66f4\u306b\u3088\u308a\u8a18\u8ff0\u65b9\u6cd5\u304c\u5909\u308f\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u65e9\u304f\u6b63\u5f0f\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u3066\u65e5\u672c\u8a9e\u3067\u3053\u306e\u8d85\u4fbf\u5229\u3067\u7d20\u6575\u306a\u65b0\u6a5f\u80fd\u3092\u52c9\u5f37\u3057\u305f\u3044\u4eca\u65e5\u3053\u306e\u9803\u3067\u3059\u3002<\/p>\n<div id=\"scid:0767317B-992E-4b12-91E0-4F059A8CECA8:129c5b45-37ae-44e8-8a5d-c1d2585d1017\" class=\"wlWriterEditableSmartContent\" style=\"float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px\">Hatena \u30bf\u30b0: <a href=\"http:\/\/b.hatena.ne.jp\/t\/Java\" rel=\"tag\">Java<\/a><\/div>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_hatena\"><a href='\/\/b.hatena.ne.jp\/add?mode=confirm&url=http%3A%2F%2Fyucchi.jp%2Fblog%2F%3Fp%3D690&title=JDK8%20Lambda%20%E3%81%9D%E3%81%AE%E4%BB%96%E3%81%84%E3%82%8D%E3%81%84%E3%82%8D%20%E3%81%AA%E3%82%93%E3%81%A7%E3%82%82%E3%81%84%E3%81%84%E3%81%8B%E3%82%89%E5%8B%95%E3%81%8B%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B%20%E3%81%9D%E3%81%AE%EF%BC%96' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='http:\/\/yucchi.jp\/blog\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/hatena.gif' alt='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' width='16' height='12' class='wp_social_bookmarking_light_img' \/><\/a><\/div>\n            <div class=\"wsbl_facebook\"><a href='http:\/\/www.facebook.com\/share.php?u=http%3A%2F%2Fyucchi.jp%2Fblog%2F%3Fp%3D690&t=JDK8%20Lambda%20%E3%81%9D%E3%81%AE%E4%BB%96%E3%81%84%E3%82%8D%E3%81%84%E3%82%8D%20%E3%81%AA%E3%82%93%E3%81%A7%E3%82%82%E3%81%84%E3%81%84%E3%81%8B%E3%82%89%E5%8B%95%E3%81%8B%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B%20%E3%81%9D%E3%81%AE%EF%BC%96' title='Facebook \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='http:\/\/yucchi.jp\/blog\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/facebook.png' alt='Facebook \u306b\u30b7\u30a7\u30a2' title='Facebook \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"http:\/\/yucchi.jp\/blog\/?p=690\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"http:\/\/yucchi.jp\/blog\/?p=690\" data-text=\"JDK8 Lambda \u305d\u306e\u4ed6\u3044\u308d\u3044\u308d \u306a\u3093\u3067\u3082\u3044\u3044\u304b\u3089\u52d5\u304b\u3057\u3066\u307f\u308b \u305d\u306e\uff16\" data-lang=\"ja\">Tweet<\/a><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>JDK8 Lambda \u305d\u306e\u4ed6\u3044\u308d\u3044\u308d \u306a\u3093\u3067\u3082\u3044\u3044\u304b\u3089\u52d5\u304b\u3057\u3066\u307f\u308b \u30b7\u30ea\u30fc\u30ba\u3082\uff16\u56de\u76ee\u3068\u306a\u308a\u307e\u3057\u305f\u3002 \u304b\u306a\u308a\u3057\u3064\u3053\u304f\u5f15\u3063\u5f35\u3063\u3066\u307e\u3059\u3002(\uffe3\u3002\uffe3;) \u6c17\u306b\u305b\u305a\u4eca\u65e5\u306f \u5973\u6027\u540c\u58eb\u306b\u3088\u308b\u58f2\u8cb7\u306e\u5408\u8a08\u91d1\u984d \u3092\u8a08\u7b97\u3055\u305b\u3066\u307f\u307e\u3057\u3087\u3046\u3002 \u5973\u6027\u306e\u58f2\u308a\u624b\u3068\u8cb7\u3044\u624b\u3092\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3066\u58f2\u308a\u5024\u306e\u5408\u8a08\u3092\u8a08\u7b97\u3059\u308c\u3070\u3088\u3055\u305d\u3046\u3067\u3059\u3002 mylambdaexamples\\MyLambdaExamples.java \/\/ \u5973\u6027\u540c\u58eb\u306b\u3088\u308b\u58f2\u8cb7\u306e\u5408\u8a08\u91d1\u984d System.out.println(&#8220;\\n&#8221;); double sum = sales.filter(s -> s.getBuyer().getGender() == Person.Se\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[17],"class_list":["post-690","post","type-post","status-publish","format-standard","hentry","category-java","tag-java"],"_links":{"self":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=690"}],"version-history":[{"count":2,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/690\/revisions"}],"predecessor-version":[{"id":786,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/690\/revisions\/786"}],"wp:attachment":[{"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=690"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/yucchi.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}