{"id":274751,"date":"2016-02-22T21:15:02","date_gmt":"2016-02-22T18:15:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=274751"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=274751","title":{"rendered":"\u041b\u0435\u043d\u0438\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432 C++"},"content":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/05b\/f52\/ba9\/05bf52ba931046cfade822f59a25b399.png\"\/><br \/>  \u0412 Scala \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u2014 Stream. \u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f (\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e) \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438:<\/p>\n<blockquote><p>The class Stream implements lazy lists where elements are only evaluated when they are needed.<\/p><\/blockquote>\n<p>  \u041c\u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043d\u0430 C++. <br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h1>\u0426\u0435\u043b\u044c<\/h1>\n<p>  \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c\u0438 \u0438 \u0447\u0442\u043e\u0431\u044b \u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u043e\u0433\u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043c\u0435\u0440\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043d\u0438\u043c.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u0431\u0435\u0433\u0430\u044f \u0432\u043f\u0435\u0440\u0435\u0434, \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">typedef lazy::list&lt;int&gt; list_type;  list_type fibonacci(int n1, int n2) {      int next = n1 + n2;      std::cout &lt;&lt; &quot;fibonacci(&quot; &lt;&lt; n1 &lt;&lt; &quot;, &quot; &lt;&lt; n2 &lt;&lt; &quot;) -&gt; &quot; &lt;&lt; n1 &lt;&lt; std::endl;      return list_type(n1, std::bind(&amp;fibonacci, n2, next)); }  int main()  {      list_type list(fibonacci(0, 1));      auto res3 = std::find_if(list.begin(), list.end(), [](int v){return v &gt; 3;});     std::cout &lt;&lt; &quot;first number greater 3 is &quot; &lt;&lt; *res3 &lt;&lt; std::endl;     std::cout &lt;&lt; std::endl;      auto res10 = std::find_if(list.begin(), list.end(), [](int v){return v &gt; 10;});     std::cout &lt;&lt; &quot;first number greater 10 is &quot; &lt;&lt; *res10 &lt;&lt; std::endl;     return 0;  }<\/code><\/pre>\n<p>  \u041d\u0430 \u0432\u044b\u0432\u043e\u0434\u0435 \u0431\u0443\u0434\u0435\u0442:<\/p>\n<pre><code>fibonacci(0, 1) -&gt; 0 fibonacci(1, 1) -&gt; 1 fibonacci(1, 2) -&gt; 1 fibonacci(2, 3) -&gt; 2 fibonacci(3, 5) -&gt; 3 fibonacci(5, 8) -&gt; 5 first number greater 3 is 5  fibonacci(8, 13) -&gt; 8 fibonacci(13, 21) -&gt; 13 first number greater 10 is 13<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043d\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f.<\/p>\n<h1>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f<\/h1>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0442\u0438\u043f\u0430:<\/p>\n<pre><code class=\"cpp\">auto iter = --list.end();<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 end, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u0430 \u044d\u0442\u043e \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u044c (\u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u044b\u0448\u0435). \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e \u043b\u0435\u043d\u0438\u0432\u043e\u043c\u0443 \u0441\u043f\u0438\u0441\u043a\u0443 \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u043d\u043e\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u2014 ForwardIterator. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0438 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435, \u0438 \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 (pop_back). \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u044f \u043d\u0435 \u0441\u0442\u0430\u043b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0430\u0432\u043a\u0443 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u0418\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437 \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439, \u0438 \u043f\u0440\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0435\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u044d\u0442\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0430. \u0418\u0437 \u044d\u0442\u0438\u0445 \u0436\u0435 \u0441\u043e\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043d\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c\u044b\u0435. \u041d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h1>\u0427\u0442\u043e \u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c?<\/h1>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u0430\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0442\u0430\u043a \u0438 \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u044b, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u044b. \u0423\u0434\u0430\u043b\u044f\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 (pop_front), \u043b\u0438\u0431\u043e \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b (clear). \u0412\u0441\u0442\u0430\u0432\u043a\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0438\u043b\u0438 \u043a\u043e\u043d\u0435\u0446 \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<p>  \u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u043e\u0434\u043d\u043e\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439, \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<pre><code class=\"cpp\">template&lt; typename T, typename Allocator = std::allocator&lt;T&gt; &gt; class list;<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt; typename T, typename Allocator = std::allocator&lt;T&gt; &gt; class list { public:     typedef list&lt;T, Allocator&gt; self_type;     typedef T value_type;     typedef std::function&lt;self_type ()&gt; func_type;     typedef __details_lazy_list::const_iterator&lt;self_type&gt; iterator;     typedef __details_lazy_list::const_iterator&lt;self_type&gt; const_iterator;      friend __details_lazy_list::const_iterator&lt;self_type&gt;;      list();     list(const self_type&amp; that);     list(self_type&amp;&amp; that);      template&lt;typename ... Args&gt;     explicit list(Args&amp;&amp;... args)     {         push_others(std::forward&lt;Args&gt;(args)...);     }      void push_back(const value_type&amp; value);     void push_back(value_type&amp;&amp; value);     void push_back(const func_type&amp; func);     void push_back(func_type&amp;&amp; func);     void push_back(const self_type&amp; that);     void push_back(self_type&amp;&amp; that);      void push_front(const value_type&amp; value);     void push_front(value_type&amp;&amp; value);     void push_front(const func_type&amp; func);     void push_front(func_type&amp;&amp; func);     void push_front(const self_type&amp; that);     void push_front(self_type&amp;&amp; that);      void clear();      bool empty() const;      const_iterator begin() const;     const_iterator end() const;  private:     typedef std::list&lt;value_type, Allocator&gt; container_type;     typedef typename container_type::iterator inner_iterator;     typedef value_type const * funcs_map_key_type;     typedef std::pair&lt;funcs_map_key_type, func_type&gt; funcs_map_value_type;     typedef std::map&lt;funcs_map_key_type, func_type&gt; funcs_map_type;      void forward(const_iterator&amp; iter) const;     void insert(inner_iterator pos, self_type&amp;&amp; that) const;      template&lt;typename Arg, typename ...Args&gt;     void push_others(Arg&amp;&amp; arg, Args&amp;&amp;... args)     {         push_back(std::forward&lt;Arg&gt;(arg));         push_others(std::forward&lt;Args&gt;(args)...);     }      template&lt;typename Arg&gt;     void push_others(Arg&amp;&amp; arg)     {         push_back(std::forward&lt;Arg&gt;(arg));     }      void push_others() {}      mutable container_type _cont;     mutable funcs_map_type _funcs; };<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">template&lt; typename lazy_list_type &gt; class const_iterator:     public std::iterator&lt;std::input_iterator_tag, typename lazy_list_type::value_type&gt; {     friend lazy_list_type; public:     typedef std::iterator&lt;std::input_iterator_tag, typename lazy_list_type::value_type&gt; base_type;     const_iterator();      typename base_type::reference const operator* () const;     typename base_type::pointer const operator-&gt; () const;      const_iterator&amp; operator++();     const_iterator operator++(int);      bool operator== (const const_iterator&amp; that);     bool operator!= (const const_iterator&amp; that); private:     typedef typename lazy_list_type::inner_iterator inner_iterator;      const_iterator(const lazy_list_type* owner, inner_iterator iter);      const lazy_list_type* _owner;     inner_iterator _iter; };<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0435\u0441\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0441 \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u0430\u043c\u0438.<\/p>\n<h2>\u0428\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.<\/h2>\n<p>  <strong>T<\/strong> \u2014 \u0442\u0438\u043f \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<p>  <strong>Allocator<\/strong> \u2014 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<h2>\u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u0442\u0438\u043f\u044b<\/h2>\n<p>  <\/p>\n<table>\n<thead>\n<tr>\n<th>\u0422\u0438\u043f<\/th>\n<th>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>value_type<\/td>\n<td>T<\/td>\n<\/tr>\n<tr>\n<td>self_type<\/td>\n<td>\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0442\u0438\u043f<\/td>\n<\/tr>\n<tr>\n<td>func_type<\/td>\n<td>\u0442\u0438\u043f \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u0424\u0443\u043d\u043a\u0442\u043e\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 self_type.<\/td>\n<\/tr>\n<tr>\n<td>iterator<\/td>\n<td>\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u0439 forward \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440<\/td>\n<\/tr>\n<tr>\n<td>const_iterator<\/td>\n<td>\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u0439 forward \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>  <\/p>\n<h2>\u041c\u0435\u0442\u043e\u0434\u044b<\/h2>\n<p>  <\/p>\n<table>\n<thead>\n<tr>\n<th>\u041c\u0435\u0442\u043e\u0434<\/th>\n<th>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>push_front<\/td>\n<td>\u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e<\/td>\n<\/tr>\n<tr>\n<td>push_back<\/td>\n<td>\u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u0432 \u043a\u043e\u043d\u0435\u0446<\/td>\n<\/tr>\n<tr>\n<td>empty<\/td>\n<td>\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043f\u0443\u0441\u0442\u044b\u043c<\/td>\n<\/tr>\n<tr>\n<td>clear<\/td>\n<td>\u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b<\/td>\n<\/tr>\n<tr>\n<td>pop_front<\/td>\n<td>\u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>  \u041c\u0435\u0442\u043e\u0434\u044b push_front \u0438 push_back \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0444\u0443\u043d\u043a\u0442\u043e\u0440, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043c\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0442\u0438\u043f\u0430 self_type.<\/p>\n<h2>\u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b<\/h2>\n<p>  <\/p>\n<table>\n<thead>\n<tr>\n<th>\u0421\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u0430<\/th>\n<th>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>list();<\/code><\/td>\n<td>\u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440<\/td>\n<\/tr>\n<tr>\n<td><code>template&lt;typename ... Args&gt; explicit list(Args&amp;&amp;... args)<\/code><\/td>\n<td>C\u043e\u0437\u0434\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u0432 \u043d\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b.<br \/>  \u041c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0442\u0438\u043f\u043e\u0432:<br \/>  <code>value_type<\/code><br \/>  <code>func_type<\/code><br \/>  <code>self_type<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>  <\/p>\n<h2>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h2>\n<p>  \u0412\u043d\u0443\u0442\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u2014 std::list \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438 std::map \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u043e\u0432. \u0424\u0443\u043d\u043a\u0442\u043e\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u0442.\u0435. self_type. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0430 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043d\u0435 \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f \u043e \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u2014 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0430\u0441\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043f\u0443\u0441\u0442\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440.<\/p>\n<p>  \u0421 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u043e\u043d \u0441\u0440\u0430\u0437\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<p>  \u041f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u0435\u0441\u0442\u044c \u043b\u0438 \u0444\u0443\u043d\u043a\u0442\u043e\u0440, \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c, \u043f\u043e\u0441\u043b\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f (push_back). \u0415\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u0430 \u043d\u0435\u0442, \u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0442\u043e\u0440 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 map, \u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442. \u041f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e, \u0432 \u043f\u0443\u0441\u0442\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0442\u043e\u0440, \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u0430 operator(), \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043d\u0443\u0436\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e (\u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0438\u043b\u0438 \u043a\u043e\u043d\u0435\u0446), \u0432 map \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u044b, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c \u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u043d\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435.<\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043f\u0430\u0440\u0443 &quot;\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u2014 \u0444\u0443\u043d\u043a\u0442\u043e\u0440&quot;, \u043d\u043e \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0438 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0430\u0440 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0448\u0435.<br \/>  \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u043e\u0432 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043c, \u0442\u043e \u043d\u0435\u0442 \u043e\u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u2014 map \u0438\u043b\u0438 unordered_map. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 map \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043f\u0430\u043c\u044f\u0442\u0438 \u0431\u0443\u0434\u0443\u0442 \u0447\u0443\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435, \u043c\u043d\u0435 \u0442\u0430\u043a \u043a\u0430\u0436\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u0435\u0441\u0442\u044c, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0430 \u0444\u0443\u043d\u043a\u0442\u043e\u0440 \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a. \u0415\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0442\u043e\u0440\u0430 \u043d\u0435\u0442 \u0438\u043b\u0438 \u043e\u043d \u0432\u0435\u0440\u043d\u0443\u043b \u043f\u0443\u0441\u0442\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c \u0441\u043f\u0438\u0441\u043a\u0435.<\/p>\n<h1>\u0417\u0430\u0447\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u043e?<\/h1>\n<p>  \u041a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043c\u0435\u043d\u044f \u043f\u043e\u0434\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 Water Pouring, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u0430\u044f \u0432 \u043b\u0435\u043a\u0446\u0438\u0438 \u043f\u043e \u044f\u0437\u044b\u043a\u0443 Scala. \u0421\u0443\u0442\u044c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c: \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0430\u043a\u0430\u043d\u043e\u0432 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043c\u0430, \u043a\u0440\u0430\u043d, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0441\u0442\u0430\u043a\u0430\u043d (\u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u043a\u0430\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e), \u0438 \u0440\u0430\u043a\u043e\u0432\u0438\u043d\u0430, \u043a\u0443\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043b\u0438\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0441\u0442\u0430\u043a\u0430\u043d\u043e\u0432. \u041d\u0430\u043f\u043e\u043b\u043d\u044f\u044f, \u043e\u043f\u0443\u0441\u0442\u043e\u0448\u0430\u044f \u0438 \u043f\u0435\u0440\u0435\u043b\u0438\u0432\u0430\u044f \u0432\u043e\u0434\u0443 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u043a\u0430\u043d\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0434\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0441\u0442\u0430\u043a\u0430\u043d\u043e\u0432. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u0442\u0430\u043a\u0430\u043d\u0430 \u043e\u0431\u044a\u0435\u043c\u043e\u043c 3 \u0438 5 \u043b\u0438\u0442\u0440\u043e\u0432, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c 4 \u043b\u0438\u0442\u0440\u0430.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/4b6\/260\/5bb\/4b62605bb72c426d97b1785f5da609eb.png\" width=\"600\"\/><br \/>  \u0411\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u043e\u0434\u044b \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0438\u0437 \u0441\u0442\u0430\u043a\u0430\u043d\u043e\u0432 \u043a\u0430\u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u0418\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439, \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0432 \u043e\u0434\u043d\u0443 \u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439: \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c, \u0432\u044b\u043b\u0438\u0442\u044c, \u043f\u0435\u0440\u0435\u043b\u0438\u0442\u044c. \u0418\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043d\u0430\u0431\u043e\u0440. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0442\u044c\u0441\u044f, \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u043d\u0430\u0431\u043e\u0440\u0430 \u043d\u043e\u0432\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/bea\/e70\/a9d\/beae70a9ddcb4a1c97fe81902d4f9886.png\" width=\"600\"\/><br \/>  \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0431\u0443\u0434\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0438\u0441\u043a\u043e\u043c\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u2014 \u0441\u0442\u0430\u043a\u0430\u043d \u0441 \u0438\u0441\u043a\u043e\u043c\u044b\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0432\u043e\u0434\u044b.<\/p>\n<p>  \u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432\u043e\u0437\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0432\u043e\u0434\u044b \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 imove:<\/p>\n<pre><code class=\"cpp\">class imove { public:     virtual state operator()(const state&amp; cur) const = 0;     virtual std::unique_ptr&lt;imove&gt; clone() const = 0;     virtual std::string to_string() const = 0;     virtual ~imove() {} };<\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <code>to_string<\/code> \u043d\u0443\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0438\u043f\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u043a\u0430\u043d &#8212; fill<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">class fill: public imove { public:     fill(unsigned glass, unsigned capacity);     state operator()(const state&amp; cur) const override;     std::unique_ptr&lt;imove&gt; clone() const override;     std::string to_string() const override; protected:     const unsigned _glass;     const unsigned _capacity; };  fill::fill(unsigned glass, unsigned capacity) :     _glass(glass),     _capacity(capacity) {}  state fill::operator()(const state&amp; cur) const {     assert(cur.size() &gt; _glass);     state next(cur);     next[_glass] = _capacity;     return next; } std::unique_ptr&lt;imove&gt; fill::clone() const {     return std::unique_ptr&lt;imove&gt;(new fill(_glass, _capacity)); } std::string fill::to_string() const {     return &quot;fill(&quot; + std::to_string(_glass) + &quot;)&quot;; }<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0412\u044b\u043b\u0438\u0442\u044c \u0432\u043e\u0434\u0443 \u0438\u0437 \u0441\u0442\u0430\u043a\u0430\u043d\u0430 &#8212; empty<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">class empty: public fill { public:     empty(unsigned glass);     std::unique_ptr&lt;imove&gt; clone() const override;     std::string to_string() const override; };  empty::empty(unsigned glass) :     fill(glass, 0) {}  std::unique_ptr&lt;imove&gt; empty::clone() const {     return std::unique_ptr&lt;imove&gt;(new empty(_glass)); }  std::string empty::to_string() const {     return &quot;empty(&quot; + std::to_string(_glass) + &quot;)&quot;; }<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0435\u0440\u0435\u043b\u0438\u0442\u044c \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0442\u0430\u043a\u0430\u043d\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 &#8212; pour<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">class pour: public imove { public:     pour(unsigned from, unsigned to, unsigned capacity_to);     state operator()(const state&amp; cur) const override;     std::unique_ptr&lt;imove&gt; clone() const override;     std::string to_string() const override; protected:     const unsigned _from;     const unsigned _to;     const unsigned _capacity_to; };  pour::pour(unsigned from, unsigned to, unsigned capacity_to) :     _from(from),     _to(to),     _capacity_to(capacity_to) {}  state pour::operator()(const state&amp; cur) const {     assert((cur.size() &gt; _from) &amp;&amp; (cur.size() &gt; _to));     assert(_capacity_to &gt;= cur[_to]);     unsigned amount = std::min(cur[_from], _capacity_to - cur[_to]);     state next(cur);     next[_from] -= amount;     next[_to] += amount;     return next; }  std::unique_ptr&lt;imove&gt; pour::clone() const {     return std::unique_ptr&lt;imove&gt;(new pour(_from, _to, _capacity_to)); }  std::string pour::to_string() const {     return &quot;pour(&quot; + std::to_string(_from) + &quot;, &quot; + std::to_string(_to) + &quot;)&quot;; }<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u043e\u0432\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438 \u043d\u0430\u0431\u043e\u0440 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0439, \u043f\u0440\u0438\u0432\u0435\u0434\u0448\u0438\u0445 \u043a \u043d\u0435\u043c\u0443. \u0417\u0430 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <code>path<\/code>:<\/p>\n<pre><code class=\"cpp\">class path { public:     path(const state&amp; initial_state);     path(const path&amp; that);      void extend(imove_ptr move);     const state&amp; end_state() const;     std::string to_string() const;     bool empty() const; private:     std::list&lt;imove_ptr&gt; _history;     state _end_state; };<\/code><\/pre>\n<p>  \u0418 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">typedef std::list&lt;path&gt; paths_list;  class water_pouring { public:     water_pouring(std::initializer_list&lt;unsigned&gt; capacities);      path solve(unsigned target); private:     typedef lazy::list&lt;paths_list&gt; list_of_paths_type;     list_of_paths_type extend(const paths_list&amp; paths);      const std::vector&lt;unsigned&gt; _capacities;     const std::vector&lt;imove_ptr&gt; _posible_moves;     const state _initial;     std::set&lt;state&gt; _explored_states;     list_of_paths_type _paths; };<\/code><\/pre>\n<p>  \u041a\u043b\u0430\u0441\u0441 \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0435\u043c\u043a\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u043a\u0430\u043d\u043e\u0432, \u0438 \u043c\u0435\u0442\u043e\u0434, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u043f\u0443\u0442\u044c \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<p>  \u041f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 extend \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043b\u0435\u043d\u0438\u0432\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<p>  \u041e\u043d \u0445\u0440\u0430\u043d\u0438\u0442 \u0435\u043c\u043a\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u043a\u0430\u043d\u043e\u0432, \u043d\u0430\u0431\u043e\u0440 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0439, \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0443\u0436\u0435 &quot;\u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435&quot; \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0441 \u0438\u0441\u0442\u043e\u0440\u0438\u0435\u0439 \u0438\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f create_moves<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">std::vector&lt;imove_ptr&gt; create_moves(const std::vector&lt;unsigned&gt;&amp; capacities) {     std::vector&lt;imove_ptr&gt; moves;     for (size_t i = 0; i &lt; capacities.size(); ++i)     {         moves.emplace_back(new empty(i));         moves.emplace_back(new fill(i, capacities[i]));         for (size_t j = 0; j &lt; capacities.size(); ++j)         {             if (i != j)                 moves.emplace_back(new pour(i, j, capacities[j]));         }     }     return moves; }<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041c\u0435\u0442\u043e\u0434 <code>water_pouring::extend<\/code>:<\/p>\n<pre><code class=\"cpp\">water_pouring::list_of_paths_type water_pouring::extend(const paths_list&amp; paths) {     paths_list next;     for (auto&amp; cur_path: paths)     {         for (auto move: _posible_moves)         {             state next_state = (*move)(cur_path.end_state());              if (_explored_states.find(next_state) == _explored_states.end())             {                 path new_path(cur_path);                 new_path.extend(move);                 next.push_back(new_path);                 _explored_states.insert(next_state);             }         }     }      if (next.empty())         return list_of_paths_type();      return list_of_paths_type(next, std::bind(&amp;water_pouring::extend, this, next)); }<\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <code>water_pouring::solve<\/code>:<\/p>\n<pre><code class=\"cpp\">path water_pouring::solve(unsigned target) {     paths_list::const_iterator solution;     auto it = std::find_if(         _paths.begin(),         _paths.end(),         [target, &amp;solution](const paths_list&amp; paths) -&gt; bool {             solution = std::find_if(                 paths.begin(),                 paths.end(),                 [target](const path&amp; p) -&gt; bool {                     auto it = std::find(                             p.end_state().begin(),                             p.end_state().end(),                             target);                     return it != p.end_state().end();                 });             return solution != paths.end();         });      if (it != _paths.end())         return *solution;      return path(state({0})); }<\/code><\/pre>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f std::find_if, \u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u0430 \u2014 \u043b\u044f\u043c\u0431\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0449\u0430\u044f \u043f\u0443\u0442\u0438 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u041b\u044f\u043c\u0431\u0434\u0430 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 solution, \u0447\u0442\u043e\u0431\u044b \u043b\u0438\u0448\u043d\u0438\u0439 \u0440\u0430\u0437 \u043d\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 it \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e.<\/p>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u0432\u0435\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>fill(1) pour(1, 0) empty(0) pour(1, 0) fill(1) pour(1, 0) --&gt; (3, 4)<\/code><\/pre>\n<p>  \u041f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443, \u0433\u0434\u0435 \u043c\u043e\u0433 \u0431\u044b \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f &quot;\u043b\u0435\u043d\u0438\u0432\u044b\u0439&quot; \u0441\u043f\u0438\u0441\u043e\u043a, \u044f \u043d\u0435 \u0441\u043c\u043e\u0433. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0438\u0434\u0435\u044f \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u0438\u0433\u043b\u044f\u043d\u0435\u0442\u0441\u044f.<\/p>\n<h1>\u0421\u0441\u044b\u043b\u043a\u0438<\/h1>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/bitbucket.org\/hokum\/lazy_list\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 lazy_list<\/a><\/li>\n<li><a href=\"https:\/\/bitbucket.org\/hokum\/waterpouringcpp\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f Water Pouring \u043d\u0430 C++<\/a><\/li>\n<li><a href=\"https:\/\/bitbucket.org\/hokum\/waterpouringscala\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f Water Pouring \u043d\u0430 Scala<\/a><\/li>\n<li><a href=\"https:\/\/www.coursera.org\/course\/progfun\">\u041a\u0443\u0440\u0441 \u043b\u0435\u043a\u0446\u0438\u0439 Functional Programming Principles in Scala \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u044b\u043b\u0430 \u0440\u0430\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0430 \u0438 \u0437\u0430\u0434\u0430\u0447\u0430 Water Pouring<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/philsquared\/Catch\">\u0414\u043b\u044f \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Catch<\/a><\/li>\n<\/ul>\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\/277737\/\"> https:\/\/habrahabr.ru\/post\/277737\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/05b\/f52\/ba9\/05bf52ba931046cfade822f59a25b399.png\"\/><br \/>  \u0412 Scala \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u2014 Stream. \u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f (\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e) \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438:<\/p>\n<blockquote><p>The class Stream implements lazy lists where elements are only evaluated when they are needed.<\/p><\/blockquote>\n<p>  \u041c\u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043d\u0430 C++.   <\/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-274751","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/274751","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=274751"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/274751\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=274751"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=274751"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=274751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}