{"action":"created","comment":{"url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/comments/155346333","pull_request_review_id":81650030,"id":155346333,"diff_hunk":"@@ -0,0 +1,68 @@\n+package ru.unn.agile.mergesort.Model;\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+public final class MergeSort {\n+\n+    private interface IPrecede<T extends Comparable<T>> {\n+        // Return if a preceds b according to the order being used\n+        boolean precede(T a, T b);\n+    }\n+    public static <T extends Comparable<T>> List<T> ascendingSort(final List<T> values) {\n+        class PrecedAscending implements IPrecede<T> {\n+            public boolean precede(final T a, final T b) {\n+                return a.compareTo(b) < 0;\n+            }\n+        }\n+        return mergeSort(values, new PrecedAscending());\n+    }\n+\n+    public static <T extends Comparable<T>> List<T> descendingSort(\n+            final List<T> values) {\n+        class PrecedDescending implements IPrecede<T> {\n+            public boolean precede(final T a, final T b) {\n+                return a.compareTo(b) > 0;\n+            }\n+        }\n+        return mergeSort(values, new PrecedDescending());\n+    }\n+\n+    private static <T extends Comparable<T>> List<T> mergeSort(final List<T> input,\n+                                                               final IPrecede<T> compareFunc) {\n+        if (input.size() < 2) {\n+            return input;\n+        }\n+        int middleIndex = input.size() / 2;\n+        List<T> firstHalf = new ArrayList<T>(input.subList(0, middleIndex));\n+        List<T> secondHalf = new ArrayList<T>(input.subList(middleIndex, input.size()));\n+        List<T> sortedFirstHalf = mergeSort(firstHalf, compareFunc);\n+        List<T> sortedSecondHalf = mergeSort(secondHalf, compareFunc);\n+        return merge(sortedFirstHalf, sortedSecondHalf, compareFunc);\n+    }\n+\n+    private static <T extends Comparable<T>> List<T> merge(final List<T> first,\n+                                                           final List<T> second,\n+                                                           final IPrecede<T> compareFunc) {\n+        int firstIndex = 0;\n+        int secondIndex = 0;\n+        ArrayList<T> result = new ArrayList<T>();\n+        while (firstIndex < first.size() && secondIndex < second.size()) {\n+            if (compareFunc.precede(second.get(secondIndex), first.get(firstIndex))) {\n+                result.add(second.get(secondIndex++));\n+            } else {\n+                result.add(first.get(firstIndex++));\n+            }\n+        }\n+        while (firstIndex < first.size()) {\n+            result.add(first.get(firstIndex++));","path":"code/merge-sort/src/main/java/ru/unn/agile/mergesort/Model/MergeSort.java","position":57,"original_position":57,"commit_id":"247b2eb0675c3d38f1ad28fe13e434d4dc170836","original_commit_id":"247b2eb0675c3d38f1ad28fe13e434d4dc170836","user":{"login":"VadimLevin","id":6630567,"avatar_url":"https://avatars0.githubusercontent.com/u/6630567?v=4","gravatar_id":"","url":"https://api.github.com/users/VadimLevin","html_url":"https://github.com/VadimLevin","followers_url":"https://api.github.com/users/VadimLevin/followers","following_url":"https://api.github.com/users/VadimLevin/following{/other_user}","gists_url":"https://api.github.com/users/VadimLevin/gists{/gist_id}","starred_url":"https://api.github.com/users/VadimLevin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VadimLevin/subscriptions","organizations_url":"https://api.github.com/users/VadimLevin/orgs","repos_url":"https://api.github.com/users/VadimLevin/repos","events_url":"https://api.github.com/users/VadimLevin/events{/privacy}","received_events_url":"https://api.github.com/users/VadimLevin/received_events","type":"User","site_admin":false},"body":"Если уж мы так много добавляем, то стоит использовать LinkedList тогда уж","created_at":"2017-12-06T20:05:37Z","updated_at":"2017-12-06T20:22:11Z","html_url":"https://github.com/UNN-VMK-Software/agile-course-practice/pull/27#discussion_r155346333","pull_request_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/27","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/comments/155346333"},"html":{"href":"https://github.com/UNN-VMK-Software/agile-course-practice/pull/27#discussion_r155346333"},"pull_request":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/27","id":154604271,"html_url":"https://github.com/UNN-VMK-Software/agile-course-practice/pull/27","diff_url":"https://github.com/UNN-VMK-Software/agile-course-practice/pull/27.diff","patch_url":"https://github.com/UNN-VMK-Software/agile-course-practice/pull/27.patch","issue_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues/27","number":27,"state":"open","locked":false,"title":"Бастракова - Лабораторная работа #1","user":{"login":"KseniaBastrakova","id":33864784,"avatar_url":"https://avatars2.githubusercontent.com/u/33864784?v=4","gravatar_id":"","url":"https://api.github.com/users/KseniaBastrakova","html_url":"https://github.com/KseniaBastrakova","followers_url":"https://api.github.com/users/KseniaBastrakova/followers","following_url":"https://api.github.com/users/KseniaBastrakova/following{/other_user}","gists_url":"https://api.github.com/users/KseniaBastrakova/gists{/gist_id}","starred_url":"https://api.github.com/users/KseniaBastrakova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KseniaBastrakova/subscriptions","organizations_url":"https://api.github.com/users/KseniaBastrakova/orgs","repos_url":"https://api.github.com/users/KseniaBastrakova/repos","events_url":"https://api.github.com/users/KseniaBastrakova/events{/privacy}","received_events_url":"https://api.github.com/users/KseniaBastrakova/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-11-24T20:20:18Z","updated_at":"2017-12-06T20:22:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"154906947cec836e05ccc8abe6651a08a89529d7","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/27/commits","review_comments_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/27/comments","review_comment_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/comments{/number}","comments_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues/27/comments","statuses_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/statuses/247b2eb0675c3d38f1ad28fe13e434d4dc170836","head":{"label":"KseniaBastrakova:lab1-tdd-merge-sort","ref":"lab1-tdd-merge-sort","sha":"247b2eb0675c3d38f1ad28fe13e434d4dc170836","user":{"login":"KseniaBastrakova","id":33864784,"avatar_url":"https://avatars2.githubusercontent.com/u/33864784?v=4","gravatar_id":"","url":"https://api.github.com/users/KseniaBastrakova","html_url":"https://github.com/KseniaBastrakova","followers_url":"https://api.github.com/users/KseniaBastrakova/followers","following_url":"https://api.github.com/users/KseniaBastrakova/following{/other_user}","gists_url":"https://api.github.com/users/KseniaBastrakova/gists{/gist_id}","starred_url":"https://api.github.com/users/KseniaBastrakova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KseniaBastrakova/subscriptions","organizations_url":"https://api.github.com/users/KseniaBastrakova/orgs","repos_url":"https://api.github.com/users/KseniaBastrakova/repos","events_url":"https://api.github.com/users/KseniaBastrakova/events{/privacy}","received_events_url":"https://api.github.com/users/KseniaBastrakova/received_events","type":"User","site_admin":false},"repo":{"id":111539005,"name":"agile-course-practice","full_name":"KseniaBastrakova/agile-course-practice","owner":{"login":"KseniaBastrakova","id":33864784,"avatar_url":"https://avatars2.githubusercontent.com/u/33864784?v=4","gravatar_id":"","url":"https://api.github.com/users/KseniaBastrakova","html_url":"https://github.com/KseniaBastrakova","followers_url":"https://api.github.com/users/KseniaBastrakova/followers","following_url":"https://api.github.com/users/KseniaBastrakova/following{/other_user}","gists_url":"https://api.github.com/users/KseniaBastrakova/gists{/gist_id}","starred_url":"https://api.github.com/users/KseniaBastrakova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KseniaBastrakova/subscriptions","organizations_url":"https://api.github.com/users/KseniaBastrakova/orgs","repos_url":"https://api.github.com/users/KseniaBastrakova/repos","events_url":"https://api.github.com/users/KseniaBastrakova/events{/privacy}","received_events_url":"https://api.github.com/users/KseniaBastrakova/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/KseniaBastrakova/agile-course-practice","description":null,"fork":true,"url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice","forks_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/forks","keys_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/teams","hooks_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/hooks","issue_events_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/issues/events{/number}","events_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/events","assignees_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/assignees{/user}","branches_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/branches{/branch}","tags_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/tags","blobs_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/git/refs{/sha}","trees_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/statuses/{sha}","languages_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/languages","stargazers_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/stargazers","contributors_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/contributors","subscribers_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/subscribers","subscription_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/subscription","commits_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/commits{/sha}","git_commits_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/git/commits{/sha}","comments_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/comments{/number}","issue_comment_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/issues/comments{/number}","contents_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/contents/{+path}","compare_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/merges","archive_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/downloads","issues_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/issues{/number}","pulls_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/pulls{/number}","milestones_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/milestones{/number}","notifications_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/labels{/name}","releases_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/releases{/id}","deployments_url":"https://api.github.com/repos/KseniaBastrakova/agile-course-practice/deployments","created_at":"2017-11-21T11:18:22Z","updated_at":"2017-11-21T11:18:24Z","pushed_at":"2017-11-26T18:51:07Z","git_url":"git://github.com/KseniaBastrakova/agile-course-practice.git","ssh_url":"git@github.com:KseniaBastrakova/agile-course-practice.git","clone_url":"https://github.com/KseniaBastrakova/agile-course-practice.git","svn_url":"https://github.com/KseniaBastrakova/agile-course-practice","homepage":null,"size":130,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"UNN-VMK-Software:master","ref":"master","sha":"9e4c744c62b76dc69be78ac5842938f449ce1818","user":{"login":"UNN-VMK-Software","id":5463209,"avatar_url":"https://avatars2.githubusercontent.com/u/5463209?v=4","gravatar_id":"","url":"https://api.github.com/users/UNN-VMK-Software","html_url":"https://github.com/UNN-VMK-Software","followers_url":"https://api.github.com/users/UNN-VMK-Software/followers","following_url":"https://api.github.com/users/UNN-VMK-Software/following{/other_user}","gists_url":"https://api.github.com/users/UNN-VMK-Software/gists{/gist_id}","starred_url":"https://api.github.com/users/UNN-VMK-Software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UNN-VMK-Software/subscriptions","organizations_url":"https://api.github.com/users/UNN-VMK-Software/orgs","repos_url":"https://api.github.com/users/UNN-VMK-Software/repos","events_url":"https://api.github.com/users/UNN-VMK-Software/events{/privacy}","received_events_url":"https://api.github.com/users/UNN-VMK-Software/received_events","type":"Organization","site_admin":false},"repo":{"id":110359761,"name":"agile-course-practice","full_name":"UNN-VMK-Software/agile-course-practice","owner":{"login":"UNN-VMK-Software","id":5463209,"avatar_url":"https://avatars2.githubusercontent.com/u/5463209?v=4","gravatar_id":"","url":"https://api.github.com/users/UNN-VMK-Software","html_url":"https://github.com/UNN-VMK-Software","followers_url":"https://api.github.com/users/UNN-VMK-Software/followers","following_url":"https://api.github.com/users/UNN-VMK-Software/following{/other_user}","gists_url":"https://api.github.com/users/UNN-VMK-Software/gists{/gist_id}","starred_url":"https://api.github.com/users/UNN-VMK-Software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UNN-VMK-Software/subscriptions","organizations_url":"https://api.github.com/users/UNN-VMK-Software/orgs","repos_url":"https://api.github.com/users/UNN-VMK-Software/repos","events_url":"https://api.github.com/users/UNN-VMK-Software/events{/privacy}","received_events_url":"https://api.github.com/users/UNN-VMK-Software/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UNN-VMK-Software/agile-course-practice","description":null,"fork":false,"url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice","forks_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/forks","keys_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/teams","hooks_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/hooks","issue_events_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues/events{/number}","events_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/events","assignees_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/assignees{/user}","branches_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/branches{/branch}","tags_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/tags","blobs_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/git/refs{/sha}","trees_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/statuses/{sha}","languages_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/languages","stargazers_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/stargazers","contributors_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/contributors","subscribers_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/subscribers","subscription_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/subscription","commits_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/commits{/sha}","git_commits_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/git/commits{/sha}","comments_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/comments{/number}","issue_comment_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues/comments{/number}","contents_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/contents/{+path}","compare_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/merges","archive_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/downloads","issues_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues{/number}","pulls_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls{/number}","milestones_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/milestones{/number}","notifications_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/labels{/name}","releases_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/releases{/id}","deployments_url":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/deployments","created_at":"2017-11-11T16:12:38Z","updated_at":"2017-11-11T16:13:06Z","pushed_at":"2017-12-06T19:55:15Z","git_url":"git://github.com/UNN-VMK-Software/agile-course-practice.git","ssh_url":"git@github.com:UNN-VMK-Software/agile-course-practice.git","clone_url":"https://github.com/UNN-VMK-Software/agile-course-practice.git","svn_url":"https://github.com/UNN-VMK-Software/agile-course-practice","homepage":null,"size":171,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"archived":false,"open_issues_count":25,"license":null,"forks":24,"open_issues":25,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/27"},"html":{"href":"https://github.com/UNN-VMK-Software/agile-course-practice/pull/27"},"issue":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues/27"},"comments":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/UNN-VMK-Software/agile-course-practice/statuses/247b2eb0675c3d38f1ad28fe13e434d4dc170836"}},"author_association":"NONE"}}
{"actor":{"display_login":"VadimLevin"}}