{"id":355507,"date":"2024-05-20T23:10:10","date_gmt":"2024-05-20T23:10:10","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=355507"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=355507","title":{"rendered":"<span>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 C++<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0432\u0438\u0434\u0435\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0442\u0430\u043a\u0430\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0438 \u043a\u043e\u0434 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d \u0441 \u043a\u043e\u0434\u043e\u043c \u0441\u0430\u043c\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u041c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u0430 \u0438\u0434\u0435\u044f \u043e\u0442\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043e\u0442 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0422\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u0412 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0421++. \u042f \u043d\u0430\u0448\u0451\u043b \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u0438 \u0432\u043e\u0442 \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c.<\/p>\n<h2>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b<\/h2>\n<h3>std::accumulate \u0438 std::reduce<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1b513add78308967429d\" data-style=\"\" id=\"650b1b513add78308967429d\" width=\"\"><\/div>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u0432\u0438\u0434\u0435\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u0432\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430: <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/reduce\" rel=\"noopener noreferrer nofollow\">std::reduce<\/a> \u0438 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/accumulate\" rel=\"noopener noreferrer nofollow\">std::accumulate<\/a> \u043d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0431\u0445\u043e\u0434\u0430 std::reduce \u043d\u0435\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043a\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 std::accumulate. \u0425\u043e\u0442\u044f \u0434\u043b\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 std::accumulate \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 std::reduce \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0435\u0431\u044f \u043b\u0443\u0447\u0448\u0435. \u0422\u0430\u043a\u0436\u0435 std::reduce \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435.<\/p>\n<h3>std::shuffle<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/64febde572e08276d79d1939\" data-style=\"\" id=\"64febde572e08276d79d1939\" width=\"\"><\/div>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/random_shuffle\" rel=\"noopener noreferrer nofollow\">std::shuffle<\/a> \u043f\u0435\u0440\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. <\/p>\n<h3>std::merge<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1c3f6f566b30a566ea03\" data-style=\"\" id=\"650b1c3f6f566b30a566ea03\" width=\"\"><\/div>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/merge\" rel=\"noopener noreferrer nofollow\">std::merge<\/a> \u0438\u0437 \u0434\u0432\u0443\u0445 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0414\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c.<\/p>\n<h3>std::rotate<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1bce72e08276d7a29373\" data-style=\"\" id=\"650b1bce72e08276d7a29373\" width=\"\"><\/div>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/rotate\" rel=\"noopener noreferrer nofollow\">std::rotate<\/a> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e. std::rotate &#171;\u0432\u0440\u0430\u0449\u0430\u0435\u0442&#187; \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 \u043b\u0435\u0432\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0442\u0430\u043a, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c.<\/p>\n<h3>std::lower_bound \u0438 std::upper_bound<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1caa627c4d3097f77582\" data-style=\"\" id=\"650b1caa627c4d3097f77582\" width=\"\"><\/div>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/lower_bound\" rel=\"noopener noreferrer nofollow\">std::lower_bound <\/a>\u0438 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/upper_bound\" rel=\"noopener noreferrer nofollow\">std::upper_bound<\/a> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430. std::lower_bound \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0440\u0430\u0432\u043d\u044b\u0439 \u0438\u0441\u043a\u043e\u043c\u043e\u043c\u0443. \u0412\u0442\u043e\u0440\u043e\u0439 &#8212; \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443. \u041e\u0431\u0430 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/equal_range\" rel=\"noopener noreferrer nofollow\">std::equal_range.<\/a><\/p>\n<h3>std::remove<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1b0ee993b176869df803\" data-style=\"\" id=\"650b1b0ee993b176869df803\" width=\"\"><\/div>\n<p>\u0412\u0438\u0434\u0435\u043e \u0432\u044b\u0448\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/remove\" rel=\"noopener noreferrer nofollow\">std::remove<\/a>. \u0423\u0434\u0430\u043b\u044f\u0435\u043c\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0430\u043c\u0430\u044f \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u043b\u0438\u043d\u0438\u044f. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c. \u042d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u043e. \u0421\u0430\u043c\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0430 erase \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 <em>(remove-erase idiom)<\/em>. <\/p>\n<h3>std::sort \u0438 std::sort_heap<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b04b03add7830896735d9\" data-style=\"\" id=\"650b04b03add7830896735d9\" width=\"\"><\/div>\n<p>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/sort\" rel=\"noopener noreferrer nofollow\">std::sort<\/a> \u0438 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/sort_heap\" rel=\"noopener noreferrer nofollow\">std::sort_heap<\/a> (\u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/make_heap\" rel=\"noopener noreferrer nofollow\">std::make_heap<\/a>). \u0412 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 std::sort \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<h3>std::reverse_copy<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1e1fff7a727696dc1a4c\" data-style=\"\" id=\"650b1e1fff7a727696dc1a4c\" width=\"\"><\/div>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/reverse_copy\" rel=\"noopener noreferrer nofollow\">std::reverse_copy<\/a>  \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<h3>std::next_permutation<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1d28962d8d30c118a10c\" data-style=\"\" id=\"650b1d28962d8d30c118a10c\" width=\"\"><\/div>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/next_permutation\" rel=\"noopener noreferrer nofollow\">std::next_permutation<\/a> \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043b\u0435\u043a\u0441\u0438\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u0437 4-\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c std::next_permutation \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e 23 \u0440\u0430\u0437\u0430.<\/p>\n<p>\u042d\u0442\u043e \u0432\u0441\u0435 \u043b\u0438\u0448\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 C++. \u0421 \u043f\u043e\u043b\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435: <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\" rel=\"noopener noreferrer nofollow\">https:\/\/en.cppreference.com\/w\/cpp\/algorithm<\/a>. \u041f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u0430\u043a\u0438\u0445 \u0435\u0449\u0451 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0432\u044b \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0443\u0432\u0438\u0434\u0435\u0442\u044c?<\/p>\n<h2>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h2>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u0438\u0434\u0435\u0435\u0439, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0439 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443. \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u0435 \u043e\u0442 \u0437\u0430\u043f\u0438\u0441\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430. <\/p>\n<pre><code class=\"cpp\">\/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443. template &lt;typename OriginalIterator> class NotifyingIterator { public:     using iterator_category = typename OriginalIterator::iterator_category;     using value_type = typename OriginalIterator::value_type;     using difference_type = typename OriginalIterator::difference_type;     using pointer = typename OriginalIterator::pointer;     using reference = typename OriginalIterator::reference;      \/*         ...         \u0437\u0434\u0435\u0441\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043be\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430         ...     *\/      \/\/ \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0430\u043a\u0442\u043e\u0432\u0430\u043d \u043a\u0430\u043a \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c     reference operator * () {         sendMessage(\"reference operator * ()\");         sendAccessEvent();         return *current_;     }          void sendAccessEvent() const {         difference_type pos = getOffset();         assert(pos >= 0);         Access event(pos);         handler_.handle(event);     }  private:         IEventHandler&amp; handler_;     OriginalIterator begin_;     OriginalIterator current_; }; <\/code><\/pre>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u0432 \u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u0439 \u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0422\u0430\u043a\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u044f \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u0441\u0438\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<pre><code class=\"cpp\">template &lt;typename Container> class EventInterpreter: public IEventHandler { public:     \/*          ...     *\/     void handle(Event&amp; event) override {         if (event.getType() != Event::Access)             return;         if (recordingIsPaused_ )             return;         \/\/ \u041a\u0430\u0436\u0434\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u0442\u043c\u0435\u0442\u043a\u0443.          \/\/ \u041f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0435 \u0432\u043b\u0438\u044f\u043b \u043d\u0430 \u0442\u0430\u0439\u043c\u0438\u043d\u0433.         pause_guard pause(*stopwatch_);         \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438.         checkWriting();     \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430         addAccess(static_cast&lt;Access&amp;>(event));     } private:     \/*          ...     *\/     Script script_;     Container copy_;     std::shared_ptr&lt;Container> original_;     std::shared_ptr&lt;Stopwatch> stopwatch_; };<\/code><\/pre>\n<p>\u0412\u0430\u0436\u043d\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u043e \u0435\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b. \u0414\u0430\u043b\u0435\u0435 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430 &#171;\u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u043d\u0438\u0435&#187; \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u0430. \u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code>std::sort_heap 24,24,22,20,20,21,21,4,8,12,10,9,20,18,18,2,1,5,4,4,4,3,8,2,3,1,8,4,18,14 932,access,29 1563,access,0 2074,write,29,24 3096,access,2 3587,access,1 4269,access,1 4920,access,0 5712,access,4 ...<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0440\u0443\u0434\u0430. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u0414\u0430\u043b\u0435\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0438. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b: \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043e\u0442\u043c\u0435\u0442\u043a\u0430 (\u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u044b), \u0442\u0438\u043f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0438 \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044c. <\/p>\n<p><a href=\"https:\/\/github.com\/dtihonov982\/StlVisualization\" rel=\"noopener noreferrer nofollow\">\u0421 \u043f\u043e\u043b\u043d\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <\/a><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/763024\/\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435.<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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:\/\/habr.com\/ru\/articles\/762554\/\"> https:\/\/habr.com\/ru\/articles\/762554\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0432\u0438\u0434\u0435\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0442\u0430\u043a\u0430\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0438 \u043a\u043e\u0434 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d \u0441 \u043a\u043e\u0434\u043e\u043c \u0441\u0430\u043c\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u041c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u0430 \u0438\u0434\u0435\u044f \u043e\u0442\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043e\u0442 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0422\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c. \u0412 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0421++. \u042f \u043d\u0430\u0448\u0451\u043b \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e, \u0438 \u0432\u043e\u0442 \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c.<\/p>\n<h2>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b<\/h2>\n<h3>std::accumulate \u0438 std::reduce<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1b513add78308967429d\" data-style=\"\" id=\"650b1b513add78308967429d\" width=\"\"><\/div>\n<p>\u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u0432\u0438\u0434\u0435\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u0432\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430: <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/reduce\" rel=\"noopener noreferrer nofollow\">std::reduce<\/a> \u0438 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/accumulate\" rel=\"noopener noreferrer nofollow\">std::accumulate<\/a> \u043d\u0430 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0431\u0445\u043e\u0434\u0430 std::reduce \u043d\u0435\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043a\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 std::accumulate. \u0425\u043e\u0442\u044f \u0434\u043b\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 std::accumulate \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 std::reduce \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0435\u0431\u044f \u043b\u0443\u0447\u0448\u0435. \u0422\u0430\u043a\u0436\u0435 std::reduce \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435.<\/p>\n<h3>std::shuffle<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/64febde572e08276d79d1939\" data-style=\"\" id=\"64febde572e08276d79d1939\" width=\"\"><\/div>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/random_shuffle\" rel=\"noopener noreferrer nofollow\">std::shuffle<\/a> \u043f\u0435\u0440\u0435\u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. <\/p>\n<h3>std::merge<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1c3f6f566b30a566ea03\" data-style=\"\" id=\"650b1c3f6f566b30a566ea03\" width=\"\"><\/div>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/merge\" rel=\"noopener noreferrer nofollow\">std::merge<\/a> \u0438\u0437 \u0434\u0432\u0443\u0445 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0414\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435 \u0441\u043b\u0438\u044f\u043d\u0438\u0435\u043c.<\/p>\n<h3>std::rotate<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1bce72e08276d7a29373\" data-style=\"\" id=\"650b1bce72e08276d7a29373\" width=\"\"><\/div>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/rotate\" rel=\"noopener noreferrer nofollow\">std::rotate<\/a> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e. std::rotate &#171;\u0432\u0440\u0430\u0449\u0430\u0435\u0442&#187; \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 \u043b\u0435\u0432\u043e\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0442\u0430\u043a, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c.<\/p>\n<h3>std::lower_bound \u0438 std::upper_bound<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1caa627c4d3097f77582\" data-style=\"\" id=\"650b1caa627c4d3097f77582\" width=\"\"><\/div>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/lower_bound\" rel=\"noopener noreferrer nofollow\">std::lower_bound <\/a>\u0438 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/upper_bound\" rel=\"noopener noreferrer nofollow\">std::upper_bound<\/a> \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430. std::lower_bound \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0440\u0430\u0432\u043d\u044b\u0439 \u0438\u0441\u043a\u043e\u043c\u043e\u043c\u0443. \u0412\u0442\u043e\u0440\u043e\u0439 &#8212; \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443. \u041e\u0431\u0430 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/equal_range\" rel=\"noopener noreferrer nofollow\">std::equal_range.<\/a><\/p>\n<h3>std::remove<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1b0ee993b176869df803\" data-style=\"\" id=\"650b1b0ee993b176869df803\" width=\"\"><\/div>\n<p>\u0412\u0438\u0434\u0435\u043e \u0432\u044b\u0448\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/remove\" rel=\"noopener noreferrer nofollow\">std::remove<\/a>. \u0423\u0434\u0430\u043b\u044f\u0435\u043c\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0430\u043c\u0430\u044f \u0432\u044b\u0441\u043e\u043a\u0430\u044f \u043b\u0438\u043d\u0438\u044f. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u043c. \u042d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u0441\u0442\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u043e. \u0421\u0430\u043c\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0430 erase \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 <em>(remove-erase idiom)<\/em>. <\/p>\n<h3>std::sort \u0438 std::sort_heap<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b04b03add7830896735d9\" data-style=\"\" id=\"650b04b03add7830896735d9\" width=\"\"><\/div>\n<p>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/sort\" rel=\"noopener noreferrer nofollow\">std::sort<\/a> \u0438 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/sort_heap\" rel=\"noopener noreferrer nofollow\">std::sort_heap<\/a> (\u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/make_heap\" rel=\"noopener noreferrer nofollow\">std::make_heap<\/a>). \u0412 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 std::sort \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<h3>std::reverse_copy<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1e1fff7a727696dc1a4c\" data-style=\"\" id=\"650b1e1fff7a727696dc1a4c\" width=\"\"><\/div>\n<p><a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/reverse_copy\" rel=\"noopener noreferrer nofollow\">std::reverse_copy<\/a>  \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<h3>std::next_permutation<\/h3>\n<div class=\"tm-iframe_temp\" data-src=\"https:\/\/embedd.srv.habr.com\/iframe\/650b1d28962d8d30c118a10c\" data-style=\"\" id=\"650b1d28962d8d30c118a10c\" width=\"\"><\/div>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\/next_permutation\" rel=\"noopener noreferrer nofollow\">std::next_permutation<\/a> \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043b\u0435\u043a\u0441\u0438\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0438\u0437 4-\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c std::next_permutation \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e 23 \u0440\u0430\u0437\u0430.<\/p>\n<p>\u042d\u0442\u043e \u0432\u0441\u0435 \u043b\u0438\u0448\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 C++. \u0421 \u043f\u043e\u043b\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435: <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/algorithm\" rel=\"noopener noreferrer nofollow\">https:\/\/en.cppreference.com\/w\/cpp\/algorithm<\/a>. \u041f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u0430\u043a\u0438\u0445 \u0435\u0449\u0451 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0432\u044b \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0443\u0432\u0438\u0434\u0435\u0442\u044c?<\/p>\n<h2>\u041a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h2>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u0438\u0434\u0435\u0435\u0439, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0439 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u043a\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443. \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u043d\u0435 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u0435 \u043e\u0442 \u0437\u0430\u043f\u0438\u0441\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430. <\/p>\n<pre><code class=\"cpp\">\/\/ \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443. template &lt;typename OriginalIterator> class NotifyingIterator { public:     using iterator_category = typename OriginalIterator::iterator_category;     using value_type = typename OriginalIterator::value_type;     using difference_type = typename OriginalIterator::difference_type;     using pointer = typename OriginalIterator::pointer;     using reference = typename OriginalIterator::reference;      \/*         ...         \u0437\u0434\u0435\u0441\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043be\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430         ...     *\/      \/\/ \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0430\u043a\u0442\u043e\u0432\u0430\u043d \u043a\u0430\u043a \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c     reference operator * () {         sendMessage(\"reference operator * ()\");         sendAccessEvent();         return *current_;     }          void sendAccessEvent() const {         difference_type pos = getOffset();         assert(pos >= 0);         Access event(pos);         handler_.handle(event);     }  private:         IEventHandler&amp; handler_;     OriginalIterator begin_;     OriginalIterator current_; }; <\/code><\/pre>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u0432 \u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0447\u0442\u0435\u043d\u0438\u0439 \u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0422\u0430\u043a\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u044f \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u0441\u0438\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<pre><code class=\"cpp\">template &lt;typename Container> class EventInterpreter: public IEventHandler { public:     \/*          ...     *\/     void handle(Event&amp; event) override {         if (event.getType() != Event::Access)             return;         if (recordingIsPaused_ )             return;         \/\/ \u041a\u0430\u0436\u0434\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u0442\u043c\u0435\u0442\u043a\u0443.          \/\/ \u041f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0435 \u0432\u043b\u0438\u044f\u043b \u043d\u0430 \u0442\u0430\u0439\u043c\u0438\u043d\u0433.         pause_guard pause(*stopwatch_);         \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f \u043b\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0438\u0441\u0438.         checkWriting();     \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430         addAccess(static_cast&lt;Access&amp;>(event));     } private:     \/*          ...     *\/     Script script_;     Container copy_;     std::shared_ptr&lt;Container> original_;     std::shared_ptr&lt;Stopwatch> stopwatch_; };<\/code><\/pre>\n<p>\u0412\u0430\u0436\u043d\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u043e \u0435\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0444\u0430\u0439\u043b. \u0414\u0430\u043b\u0435\u0435 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430 &#171;\u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u043d\u0438\u0435&#187; \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u0430. \u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code>std::sort_heap 24,24,22,20,20,21,21,4,8,12,10,9,20,18,18,2,1,5,4,4,4,3,8,2,3,1,8,4,18,14 932,access,29 1563,access,0 2074,write,29,24 3096,access,2 3587,access,1 4269,access,1 4920,access,0 5712,access,4 ...<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043b\u043e\u0433-\u0444\u0430\u0439\u043b\u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0440\u0443\u0434\u0430. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430. \u0414\u0430\u043b\u0435\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0442\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0438. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b: \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043e\u0442\u043c\u0435\u0442\u043a\u0430 (\u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u044b), \u0442\u0438\u043f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0438 \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044c. <\/p>\n<p><a href=\"https:\/\/github.com\/dtihonov982\/StlVisualization\" rel=\"noopener noreferrer nofollow\">\u0421 \u043f\u043e\u043b\u043d\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 <\/a><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/articles\/763024\/\" rel=\"noopener noreferrer nofollow\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435.<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \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:\/\/habr.com\/ru\/articles\/762554\/\"> https:\/\/habr.com\/ru\/articles\/762554\/<\/a><br \/><\/br><\/br><\/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-355507","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/355507","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=355507"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/355507\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=355507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=355507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=355507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}