{"action":"created","comment":{"url":"https://api.github.com/repos/bagedan/EPAM-JMP/pulls/comments/59542035","id":59542035,"diff_hunk":"@@ -23,101 +23,196 @@ public DataProcessor(List<RoadAccident> roadAccidentList){\n \n     /**\n      * Return road accident with matching index\n+     *\n      * @param index\n      * @return\n      */\n-    public RoadAccident getAccidentByIndex7(String index){\n+    public RoadAccident getAccidentByIndex7(String index) {\n+        Iterator<RoadAccident> roadAccidentIterator = roadAccidentList.iterator();\n+        while (roadAccidentIterator.hasNext()) {\n+            RoadAccident current = roadAccidentIterator.next();\n+            if (current.getAccidentId().equals(index)) {\n+                return current;\n+            }\n+        }\n         return null;\n     }\n \n \n     /**\n      * filter list by longtitude and latitude values, including boundaries\n+     *\n      * @param minLongitude\n      * @param maxLongitude\n      * @param minLatitude\n      * @param maxLatitude\n      * @return\n      */\n-    public Collection<RoadAccident> getAccidentsByLocation7(float minLongitude, float maxLongitude, float minLatitude, float maxLatitude){\n-        return null;\n+    public Collection<RoadAccident> getAccidentsByLocation7(float minLongitude, float maxLongitude, float minLatitude, float maxLatitude) {\n+        ArrayList<RoadAccident> result = new ArrayList<>();\n+\n+        Iterator<RoadAccident> roadAccidentIterator = roadAccidentList.iterator();\n+\n+        while (roadAccidentIterator.hasNext()) {\n+            RoadAccident current = roadAccidentIterator.next();\n+            if (minLongitude <= current.getLongitude() && current.getLongitude() <= maxLongitude &&\n+                    minLatitude <= current.getLatitude() && current.getLatitude() <= maxLatitude) {\n+                result.add(current);\n+            }\n+        }\n+\n+        return result;\n     }\n \n     /**\n      * count incidents by road surface conditions\n      * ex:\n      * wet -> 2\n      * dry -> 5\n+     *\n      * @return\n      */\n-    public Map<String, Long> getCountByRoadSurfaceCondition7(){\n-        return null;\n+    public Map<String, Long> getCountByRoadSurfaceCondition7() {\n+        HashMap<String, Long> result = new HashMap<>();\n+        Iterator<RoadAccident> roadAccidentIterator = roadAccidentList.iterator();\n+\n+        while (roadAccidentIterator.hasNext()) {\n+            RoadAccident current = roadAccidentIterator.next();\n+            String roadSurfaceConditions = current.getRoadSurfaceConditions();\n+\n+            Long newValue = result.get(roadSurfaceConditions) == null ? 1 : Long.valueOf(result.get(roadSurfaceConditions) + 1);\n+            result.put(roadSurfaceConditions, newValue);\n+        }\n+\n+        return result;\n     }\n \n     /**\n      * find the weather conditions which caused the top 3 number of incidents\n      * as example if there were 10 accidence in rain, 5 in snow, 6 in sunny and 1 in foggy, then your result list should contain {rain, sunny, snow} - top three in decreasing order\n+     *\n      * @return\n      */\n-    public List<String> getTopThreeWeatherCondition7(){\n-        return null;\n+    public List<String> getTopThreeWeatherCondition7() {\n+        List<String> result = new ArrayList<>();\n+\n+        Map<String, Long> accidentsByWeatherConditions = new HashMap<>();\n+\n+        Iterator<RoadAccident> roadAccidentIterator = roadAccidentList.iterator();\n+\n+        while (roadAccidentIterator.hasNext()) {\n+            RoadAccident current = roadAccidentIterator.next();\n+            String weatherConditions = current.getWeatherConditions();\n+\n+            Long newValue = accidentsByWeatherConditions.get(weatherConditions) == null ? 1 : Long.valueOf(accidentsByWeatherConditions.get(weatherConditions) + 1);\n+            accidentsByWeatherConditions.put(weatherConditions, newValue);\n+        }\n+\n+        List<Map.Entry<String, Long>> listAccidentsByConditions = new LinkedList<Map.Entry<String, Long>>(accidentsByWeatherConditions.entrySet());\n+\n+        Collections.sort(listAccidentsByConditions, new Comparator<Map.Entry<String, Long>>(){\n+\n+            @Override\n+            public int compare(Map.Entry<String, Long> o1, Map.Entry<String, Long> o2) {\n+                // Decreasing order\n+                return o2.getValue().compareTo(o1.getValue());\n+            }\n+        });\n+\n+        List<Map.Entry<String, Long>> topAccidents = listAccidentsByConditions.subList(0, 3);\n+\n+        for (Map.Entry<String, Long>  accident: topAccidents) {\n+            result.add(accident.getKey());\n+        }\n+\n+        return result;","path":"src/main/java/com/epam/processor/DataProcessor.java","position":137,"original_position":137,"commit_id":"729aa2e7ec71030700f9b768cda112427d98db79","original_commit_id":"729aa2e7ec71030700f9b768cda112427d98db79","user":{"login":"bagedan","id":4011890,"avatar_url":"https://avatars.githubusercontent.com/u/4011890?v=3","gravatar_id":"","url":"https://api.github.com/users/bagedan","html_url":"https://github.com/bagedan","followers_url":"https://api.github.com/users/bagedan/followers","following_url":"https://api.github.com/users/bagedan/following{/other_user}","gists_url":"https://api.github.com/users/bagedan/gists{/gist_id}","starred_url":"https://api.github.com/users/bagedan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bagedan/subscriptions","organizations_url":"https://api.github.com/users/bagedan/orgs","repos_url":"https://api.github.com/users/bagedan/repos","events_url":"https://api.github.com/users/bagedan/events{/privacy}","received_events_url":"https://api.github.com/users/bagedan/received_events","type":"User","site_admin":false},"body":"Again, your solution is totally fine, but look at [this ](https://github.com/bagedan/EPAM-JMP/pull/3/files#diff-9566c4a7c6afefe7dea1a80cbc457ad8R84)one as well - quite interesting usage of multimap","created_at":"2016-04-13T12:55:23Z","updated_at":"2016-04-13T12:55:23Z","html_url":"https://github.com/bagedan/EPAM-JMP/pull/6#discussion_r59542035","pull_request_url":"https://api.github.com/repos/bagedan/EPAM-JMP/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/bagedan/EPAM-JMP/pulls/comments/59542035"},"html":{"href":"https://github.com/bagedan/EPAM-JMP/pull/6#discussion_r59542035"},"pull_request":{"href":"https://api.github.com/repos/bagedan/EPAM-JMP/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/bagedan/EPAM-JMP/pulls/6","id":66254237,"html_url":"https://github.com/bagedan/EPAM-JMP/pull/6","diff_url":"https://github.com/bagedan/EPAM-JMP/pull/6.diff","patch_url":"https://github.com/bagedan/EPAM-JMP/pull/6.patch","issue_url":"https://api.github.com/repos/bagedan/EPAM-JMP/issues/6","number":6,"state":"open","locked":false,"title":"HomeTask - collections","user":{"login":"tribalspirit","id":2981191,"avatar_url":"https://avatars.githubusercontent.com/u/2981191?v=3","gravatar_id":"","url":"https://api.github.com/users/tribalspirit","html_url":"https://github.com/tribalspirit","followers_url":"https://api.github.com/users/tribalspirit/followers","following_url":"https://api.github.com/users/tribalspirit/following{/other_user}","gists_url":"https://api.github.com/users/tribalspirit/gists{/gist_id}","starred_url":"https://api.github.com/users/tribalspirit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tribalspirit/subscriptions","organizations_url":"https://api.github.com/users/tribalspirit/orgs","repos_url":"https://api.github.com/users/tribalspirit/repos","events_url":"https://api.github.com/users/tribalspirit/events{/privacy}","received_events_url":"https://api.github.com/users/tribalspirit/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-13T01:39:08Z","updated_at":"2016-04-13T12:55:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d07cb5ac5b1988fdecb0d704246393f0e3361116","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bagedan/EPAM-JMP/pulls/6/commits","review_comments_url":"https://api.github.com/repos/bagedan/EPAM-JMP/pulls/6/comments","review_comment_url":"https://api.github.com/repos/bagedan/EPAM-JMP/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bagedan/EPAM-JMP/issues/6/comments","statuses_url":"https://api.github.com/repos/bagedan/EPAM-JMP/statuses/729aa2e7ec71030700f9b768cda112427d98db79","head":{"label":"tribalspirit:master","ref":"master","sha":"729aa2e7ec71030700f9b768cda112427d98db79","user":{"login":"tribalspirit","id":2981191,"avatar_url":"https://avatars.githubusercontent.com/u/2981191?v=3","gravatar_id":"","url":"https://api.github.com/users/tribalspirit","html_url":"https://github.com/tribalspirit","followers_url":"https://api.github.com/users/tribalspirit/followers","following_url":"https://api.github.com/users/tribalspirit/following{/other_user}","gists_url":"https://api.github.com/users/tribalspirit/gists{/gist_id}","starred_url":"https://api.github.com/users/tribalspirit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tribalspirit/subscriptions","organizations_url":"https://api.github.com/users/tribalspirit/orgs","repos_url":"https://api.github.com/users/tribalspirit/repos","events_url":"https://api.github.com/users/tribalspirit/events{/privacy}","received_events_url":"https://api.github.com/users/tribalspirit/received_events","type":"User","site_admin":false},"repo":{"id":56110617,"name":"EPAM-JMP","full_name":"tribalspirit/EPAM-JMP","owner":{"login":"tribalspirit","id":2981191,"avatar_url":"https://avatars.githubusercontent.com/u/2981191?v=3","gravatar_id":"","url":"https://api.github.com/users/tribalspirit","html_url":"https://github.com/tribalspirit","followers_url":"https://api.github.com/users/tribalspirit/followers","following_url":"https://api.github.com/users/tribalspirit/following{/other_user}","gists_url":"https://api.github.com/users/tribalspirit/gists{/gist_id}","starred_url":"https://api.github.com/users/tribalspirit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tribalspirit/subscriptions","organizations_url":"https://api.github.com/users/tribalspirit/orgs","repos_url":"https://api.github.com/users/tribalspirit/repos","events_url":"https://api.github.com/users/tribalspirit/events{/privacy}","received_events_url":"https://api.github.com/users/tribalspirit/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tribalspirit/EPAM-JMP","description":"","fork":true,"url":"https://api.github.com/repos/tribalspirit/EPAM-JMP","forks_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/forks","keys_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/teams","hooks_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/hooks","issue_events_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/issues/events{/number}","events_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/events","assignees_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/assignees{/user}","branches_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/branches{/branch}","tags_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/tags","blobs_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/git/refs{/sha}","trees_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/statuses/{sha}","languages_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/languages","stargazers_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/stargazers","contributors_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/contributors","subscribers_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/subscribers","subscription_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/subscription","commits_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/commits{/sha}","git_commits_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/git/commits{/sha}","comments_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/comments{/number}","issue_comment_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/issues/comments{/number}","contents_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/contents/{+path}","compare_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/merges","archive_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/downloads","issues_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/issues{/number}","pulls_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/pulls{/number}","milestones_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/milestones{/number}","notifications_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/labels{/name}","releases_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/releases{/id}","deployments_url":"https://api.github.com/repos/tribalspirit/EPAM-JMP/deployments","created_at":"2016-04-13T01:23:55Z","updated_at":"2016-04-13T01:23:56Z","pushed_at":"2016-04-13T01:37:44Z","git_url":"git://github.com/tribalspirit/EPAM-JMP.git","ssh_url":"git@github.com:tribalspirit/EPAM-JMP.git","clone_url":"https://github.com/tribalspirit/EPAM-JMP.git","svn_url":"https://github.com/tribalspirit/EPAM-JMP","homepage":null,"size":2725,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bagedan:master","ref":"master","sha":"387197092f5f3355172f90e75a699ecb74324b9b","user":{"login":"bagedan","id":4011890,"avatar_url":"https://avatars.githubusercontent.com/u/4011890?v=3","gravatar_id":"","url":"https://api.github.com/users/bagedan","html_url":"https://github.com/bagedan","followers_url":"https://api.github.com/users/bagedan/followers","following_url":"https://api.github.com/users/bagedan/following{/other_user}","gists_url":"https://api.github.com/users/bagedan/gists{/gist_id}","starred_url":"https://api.github.com/users/bagedan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bagedan/subscriptions","organizations_url":"https://api.github.com/users/bagedan/orgs","repos_url":"https://api.github.com/users/bagedan/repos","events_url":"https://api.github.com/users/bagedan/events{/privacy}","received_events_url":"https://api.github.com/users/bagedan/received_events","type":"User","site_admin":false},"repo":{"id":55405358,"name":"EPAM-JMP","full_name":"bagedan/EPAM-JMP","owner":{"login":"bagedan","id":4011890,"avatar_url":"https://avatars.githubusercontent.com/u/4011890?v=3","gravatar_id":"","url":"https://api.github.com/users/bagedan","html_url":"https://github.com/bagedan","followers_url":"https://api.github.com/users/bagedan/followers","following_url":"https://api.github.com/users/bagedan/following{/other_user}","gists_url":"https://api.github.com/users/bagedan/gists{/gist_id}","starred_url":"https://api.github.com/users/bagedan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bagedan/subscriptions","organizations_url":"https://api.github.com/users/bagedan/orgs","repos_url":"https://api.github.com/users/bagedan/repos","events_url":"https://api.github.com/users/bagedan/events{/privacy}","received_events_url":"https://api.github.com/users/bagedan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bagedan/EPAM-JMP","description":"","fork":false,"url":"https://api.github.com/repos/bagedan/EPAM-JMP","forks_url":"https://api.github.com/repos/bagedan/EPAM-JMP/forks","keys_url":"https://api.github.com/repos/bagedan/EPAM-JMP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bagedan/EPAM-JMP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bagedan/EPAM-JMP/teams","hooks_url":"https://api.github.com/repos/bagedan/EPAM-JMP/hooks","issue_events_url":"https://api.github.com/repos/bagedan/EPAM-JMP/issues/events{/number}","events_url":"https://api.github.com/repos/bagedan/EPAM-JMP/events","assignees_url":"https://api.github.com/repos/bagedan/EPAM-JMP/assignees{/user}","branches_url":"https://api.github.com/repos/bagedan/EPAM-JMP/branches{/branch}","tags_url":"https://api.github.com/repos/bagedan/EPAM-JMP/tags","blobs_url":"https://api.github.com/repos/bagedan/EPAM-JMP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bagedan/EPAM-JMP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bagedan/EPAM-JMP/git/refs{/sha}","trees_url":"https://api.github.com/repos/bagedan/EPAM-JMP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bagedan/EPAM-JMP/statuses/{sha}","languages_url":"https://api.github.com/repos/bagedan/EPAM-JMP/languages","stargazers_url":"https://api.github.com/repos/bagedan/EPAM-JMP/stargazers","contributors_url":"https://api.github.com/repos/bagedan/EPAM-JMP/contributors","subscribers_url":"https://api.github.com/repos/bagedan/EPAM-JMP/subscribers","subscription_url":"https://api.github.com/repos/bagedan/EPAM-JMP/subscription","commits_url":"https://api.github.com/repos/bagedan/EPAM-JMP/commits{/sha}","git_commits_url":"https://api.github.com/repos/bagedan/EPAM-JMP/git/commits{/sha}","comments_url":"https://api.github.com/repos/bagedan/EPAM-JMP/comments{/number}","issue_comment_url":"https://api.github.com/repos/bagedan/EPAM-JMP/issues/comments{/number}","contents_url":"https://api.github.com/repos/bagedan/EPAM-JMP/contents/{+path}","compare_url":"https://api.github.com/repos/bagedan/EPAM-JMP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bagedan/EPAM-JMP/merges","archive_url":"https://api.github.com/repos/bagedan/EPAM-JMP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bagedan/EPAM-JMP/downloads","issues_url":"https://api.github.com/repos/bagedan/EPAM-JMP/issues{/number}","pulls_url":"https://api.github.com/repos/bagedan/EPAM-JMP/pulls{/number}","milestones_url":"https://api.github.com/repos/bagedan/EPAM-JMP/milestones{/number}","notifications_url":"https://api.github.com/repos/bagedan/EPAM-JMP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bagedan/EPAM-JMP/labels{/name}","releases_url":"https://api.github.com/repos/bagedan/EPAM-JMP/releases{/id}","deployments_url":"https://api.github.com/repos/bagedan/EPAM-JMP/deployments","created_at":"2016-04-04T11:18:51Z","updated_at":"2016-04-13T11:40:19Z","pushed_at":"2016-04-13T11:38:49Z","git_url":"git://github.com/bagedan/EPAM-JMP.git","ssh_url":"git@github.com:bagedan/EPAM-JMP.git","clone_url":"https://github.com/bagedan/EPAM-JMP.git","svn_url":"https://github.com/bagedan/EPAM-JMP","homepage":null,"size":2731,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":9,"forks":17,"open_issues":9,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bagedan/EPAM-JMP/pulls/6"},"html":{"href":"https://github.com/bagedan/EPAM-JMP/pull/6"},"issue":{"href":"https://api.github.com/repos/bagedan/EPAM-JMP/issues/6"},"comments":{"href":"https://api.github.com/repos/bagedan/EPAM-JMP/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/bagedan/EPAM-JMP/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/bagedan/EPAM-JMP/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bagedan/EPAM-JMP/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/bagedan/EPAM-JMP/statuses/729aa2e7ec71030700f9b768cda112427d98db79"}}}}