{"id":275008,"date":"2016-02-26T11:25:04","date_gmt":"2016-02-26T08:25:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=275008"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=275008","title":{"rendered":"\u041e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u043c\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Google Guava"},"content":{"rendered":"<p>       <b>1. \u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/b><\/p>\n<p>  \u0412 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u043c\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Google Guava. \u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0435\u043b\u0435\u043d\u043e \u0435\u0451 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0445 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 (\u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438) \u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.<a name=\"habracut\"><\/a><\/p>\n<p>  <b>2. \u041a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u0438\u043a\u0430<\/b><\/p>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438. \u041d\u0430\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b \u0442\u0435\u043c\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0440\u0435\u0441\u0443\u0440\u0441\u0430 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432 (\u0431\u0435\u0437 \u043e\u0442\u043a\u0430\u0437\u043e\u0432). \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 (\u0432 \u0440\u0430\u0437\u0440\u0435\u0437\u0435 \u043f\u043e \u0442\u0435\u043c\u0430\u043c). \u041f\u0443\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043f\u044f\u0442\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432 (\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u2014 \u044d\u0442\u043e \u0442\u0435\u043c\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430). \u041c\u044b \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0441\u0430\u0439\u0442\u0430 (\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0445 6 \u0434\u043b\u044f \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0438 \u043c\u0435\u0441\u0442\u0430) \u043e\u0447\u0435\u043d\u044c \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0441\u043c\u043e\u0442\u0440\u044f\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 T1:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/928\/68f\/3ce\/92868f3cef5845338ed0db618a39fdce.png\"\/><\/p>\n<p>  \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/217\/f99\/d14\/217f99d14d344188904e4aa826289267.png\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/6da\/858\/c15\/6da858c1580241ffa31bcc848bd2ea47.png\"\/><\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u0438\u043a\u0438. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u044f\u0432\u0438\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u0414\u0430\u043d\u043d\u0430\u044f \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e\u0433\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432). \u0415\u0441\u043b\u0438 \u043c\u044b \u0435\u0433\u043e \u0437\u043d\u0430\u0435\u043c, \u0442\u043e \u0438 \u0437\u043d\u0430\u0435\u043c \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b \u0447\u0438\u0441\u043b\u0430 9 \u0440\u0430\u0432\u0435\u043d 362880 (\u0432 R \u044d\u0442\u043e factorial(9)).<\/p>\n<p>  \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u044c \u0443\u0437\u043d\u0430\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438 \u044f \u043c\u043e\u0433\u0443 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 (\u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0438\u0437 n \u043f\u043e k). \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430. \u041a\u0430\u043a \u0432\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0431\u044b \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b R, \u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0431\u044b:  <\/p>\n<pre><code>&gt; choose(19,3) [1] 969 <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u044f \u0431\u0443\u0434\u0443 \u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e 3 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 19 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445, \u0442\u043e \u044f \u0441\u043c\u043e\u0433\u0443 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 969 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439. \u0412\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a Java, \u0430 \u0442\u043e\u0447\u043d\u0435\u0435 \u043a Google Guava, \u0433\u0434\u0435 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c:  <\/p>\n<pre><code class=\"java\">logger.trace(LongMath.factorial(9)); \/\/ 362880 logger.trace(LongMath.binomial(19, 3)); \/\/ 969 <\/code><\/pre>\n<p>  <b>3. \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432<\/b><\/p>\n<p>  \u041f\u0440\u0438 \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 (\u043e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u0438\u043c\u043f\u043e\u0440\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u043f\u043e API \u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 RabbitMQ, Redis, Tarantool) \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0441\u0445\u0435\u043c\u0443: \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0438\u043c\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043b\u044e\u0447\u0430, \u0430 \u0438\u043c\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u0432\u0438\u0434\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c:  <\/p>\n<pre><code class=\"java\">Multimap&lt;String, String&gt; sets = ArrayListMultimap.create(); \t\t sets.put(&quot;main&quot;, &quot;a&quot;); sets.put(&quot;new&quot;, &quot;b&quot;); sets.put(&quot;new&quot;, &quot;c&quot;);  logger.trace(sets.get(&quot;main&quot;)); \/\/ [a] logger.trace(sets.get(&quot;new&quot;)); \/\/ [b, c] logger.trace(sets.asMap()); \/\/ {new=[b, c], main=[a]}  \/\/ \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u0441\u0442\u0438\u043b\u0435 \u00ab\u041f\u0440\u0438\u0432\u0435\u0442 \u041c\u0438\u0440!\u00bb Gson gson = new Gson(); Jedis jedis = new Jedis(&quot;localhost&quot;);  jedis.set(&quot;habr&quot;, gson.toJson(sets.asMap())); logger.trace(jedis.get(&quot;habr&quot;)); \/\/ {&quot;new&quot;:[&quot;b&quot;,&quot;c&quot;],&quot;main&quot;:[&quot;a&quot;]} <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430 PHP. \u041e\u0431\u044b\u0447\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u043e\u0434\u043d\u0430\u043a\u043e, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 (\u043d\u0430 \u00ab\u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435\u00bb \u043b\u0443\u0447\u0448\u0435 \u0442\u0430\u043a \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c) \u044f \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0438\u0445 \u0434\u043b\u0438\u043d\u0443, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u044f\u043c\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0440\u043e\u0434\u043d\u043e\u043c \u0434\u043b\u044f Redis \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0435:  <\/p>\n<pre><code class=\"php\">$fp = fsockopen('127.0.0.1', 6379);  fwrite($fp,  &quot;*2\\r\\n\\$3\\r\\nGET\\r\\n\\$4\\r\\nhabr\\r\\n&quot;); echo fgets($fp); echo fgets($fp); <\/code><\/pre>\n<p>  \u0412\u0438\u0436\u0443 \u0441\u043c\u044b\u0441\u043b \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c \u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0438\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u043b\u0438 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e, \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 readLines, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0441\u0442\u044c \u0443 \u043a\u043b\u0430\u0441\u0441\u0430 Files (\u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439) \u0438 \u0443 \u043a\u043b\u0430\u0441\u0441\u0430 Resources (\u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439, \u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0439 \u043f\u043e HTTP \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 \u0432 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435). \u0418\u043d\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0433\u0434\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 \u0438\u043b\u0438 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u043c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u043e\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0437 \u043d\u0438\u0445:  <\/p>\n<pre><code class=\"java\">List&lt;String&gt; eventNames = Resources.readLines(new URL(url), Charsets.UTF_8); logger.trace(eventNames);  List&lt;String&gt; set = Splitter.on(',').trimResults().omitEmptyStrings().splitToList(&quot;a,b,b,b,c&quot;); logger.trace(set); \/\/ [a, b, b, b, c]  String test = Joiner.on(&quot; - &quot;).join(set); logger.trace(test); \/\/ a - b - b - b - c <\/code><\/pre>\n<p>  <b>4. \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u043c\u0438<\/b><\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0438 \u0434\u0430\u0434\u0438\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c:  <\/p>\n<pre><code class=\"java\">Set&lt;String&gt; a = ImmutableSet.of(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;); Set&lt;String&gt; b = ImmutableSet.of(&quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;);  logger.trace(Sets.union(a, b)); \/\/ [a, b, c, d, e, f] logger.trace(Sets.intersection(a, b)); \/\/ [c, d] logger.trace(Sets.difference(a, b)); \/\/ [a, b] logger.trace(Sets.symmetricDifference(a, b)); \/\/ [a, b, e, f] <\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u044b\u043b\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438:  <\/p>\n<ul>\n<li>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 (union) \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 (\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0433\u043b\u043e\u0442\u0438\u043b \u0432 \u0441\u0435\u0431\u044f \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043e\u0431\u043e\u0438\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0431\u0435\u0437 \u0434\u0443\u0431\u043b\u0435\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043b\u044e\u0431\u043e\u0439 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u044d\u0442\u0438\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432, \u0441\u0442\u0430\u043b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430.<\/li>\n<li>\u041f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 (intersection) \u043f\u043e\u0440\u043e\u0436\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0435 (\u0435\u0441\u0442\u044c \u0443 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438 \u0443 \u0432\u0442\u043e\u0440\u043e\u0433\u043e) \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b. \u0427\u0442\u043e \u0443 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u043e\u0431\u0449\u0435\u0433\u043e, \u0442\u043e \u0438 \u0431\u0443\u0434\u0435\u0442 \u0432 \u043d\u043e\u0432\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435.<\/li>\n<li>\u0421 \u043f\u043e\u043d\u044f\u0442\u0438\u0435\u043c \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438 (difference) \u0442\u043e\u0436\u0435 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u043d\u043e\u0432\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u043f\u0435\u0440\u0432\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u043d\u043e \u043d\u0435 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0435.<\/li>\n<li>\u0415\u0441\u0442\u044c \u0435\u0449\u0451 \u0438 \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u0435, \u043a\u0430\u043a \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044c (symmetricDifference). \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0431\u043e\u0438\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432, \u043a\u0440\u043e\u043c\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0451\u043d\u043d\u044b\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0441 \u0441\u0430\u043c\u0438\u043c \u0441\u043e\u0431\u043e\u0439, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u0443\u0441\u0442\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e.<\/li>\n<\/ul>\n<p>  <b>5. \u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b <\/b><\/p>\n<p>  \u0425\u043e\u0447\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e HashMultiset, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0412\u043f\u043e\u043b\u043d\u0435 \u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0439:   <\/p>\n<pre><code class=\"java\">HashMultiset&lt;String&gt; habr = HashMultiset.create(); habr.add(&quot;habr_7&quot;); habr.add(&quot;habr_5&quot;); habr.add(&quot;habr_5&quot;); habr.add(&quot;habr_5&quot;); habr.add(&quot;habr_5&quot;); habr.add(&quot;habr_9&quot;); habr.add(&quot;habr_9&quot;); habr.add(&quot;habr_1&quot;); habr.add(&quot;habr_1&quot;); habr.add(&quot;habr_1&quot;);  logger.trace(habr); \/\/ [habr_1 x 3, habr_9 x 2, habr_5 x 4, habr_7]  logger.trace(habr.count(&quot;habr_1&quot;)); \/\/ 3 logger.trace(habr.count(&quot;habr_5&quot;)); \/\/ 4 logger.trace(habr.count(&quot;habr_0&quot;)); \/\/ 0  ImmutableMultiset&lt;String&gt; highestRank = Multisets.copyHighestCountFirst(habr); logger.trace(highestRank); \/\/ [habr_5 x 4, habr_1 x 3, habr_9 x 2, habr_7] <\/code><\/pre>\n<p>  <b>6. \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/b><\/p>\n<p>  \u041e\u0447\u0435\u043d\u044c \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u0430\u044f \u0441\u043a\u0440\u043e\u043c\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u0442\u043a\u0430 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f\u043c \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c \u0438 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u044f\u0434\u0435 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u043c\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Google Guava.               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/278009\/\"> https:\/\/habrahabr.ru\/post\/278009\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <b>1. \u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/b><\/p>\n<p>  \u0412 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430\u043c\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Google Guava. \u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e, \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0435\u043b\u0435\u043d\u043e \u0435\u0451 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0447\u0435\u0441\u043a\u0438\u0445 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 (\u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438) \u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-275008","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/275008","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=275008"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/275008\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=275008"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=275008"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=275008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}