{"action":"created","comment":{"url":"https://api.github.com/repos/serge29041996/MateAcademy/pulls/comments/271759366","pull_request_review_id":222231278,"id":271759366,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI3MTc1OTM2Ng==","diff_hunk":"@@ -0,0 +1,224 @@\n+package com.homework5;\n+\n+/**\n+ * Realization of HashMap.\n+ */\n+public class MyHashMap<K, V> {\n+  private static final int INITIAL_CAPACITY = 16;\n+  private static final double INITIAL_LOAD_FACTOR = 0.7;\n+  private int size = 0;\n+  private double loadFactor;\n+  private Node<K,V>[] table;\n+\n+  public MyHashMap() {\n+    this(INITIAL_CAPACITY);\n+  }\n+\n+  public MyHashMap(int capacity) {\n+    this(capacity, INITIAL_LOAD_FACTOR);\n+  }\n+\n+  /**\n+   * Constructor with capacity and load factor.\n+   * @param capacity size of table for saving data\n+   * @param loadFactor max coefficient, when table expands\n+   * @throws IllegalArgumentException when capacity less than 2 or load factor less than 0\n+   */\n+  public MyHashMap(int capacity, double loadFactor) {\n+    if (capacity < 2) {\n+      throw new IllegalArgumentException(\"Capacity cannot be less than 2\");\n+    }\n+    if (loadFactor < 0) {\n+      throw new IllegalArgumentException(\"Load factor cannot be less than 0\");\n+    }\n+    this.loadFactor = loadFactor;\n+    this.table = (Node<K, V>[]) new Node[capacity];\n+  }\n+\n+  /**\n+   * Put new key and value if their has not in table or rewrite value for existing key.\n+   * @param key key for getting\n+   * @param value value, which associated with key\n+   */\n+  public void put(K key, V value) {\n+    int[] hashAndIndex = computeHashAndIndex(key);\n+    int indexForSaving = hashAndIndex[0];\n+    int hash = hashAndIndex[1];\n+    Node<K, V> elementTable = table[indexForSaving];\n+    if (elementTable == null) {\n+      table[indexForSaving] = new Node<>(hash, key, value, null);\n+      size++;\n+    } else if (hash == elementTable.hash\n+        && (key == elementTable.key || checkEquals(key, elementTable.key))) {\n+      elementTable.value = value;\n+    } else {\n+      table[indexForSaving] = new Node<>(hash, key, value, elementTable);\n+      size++;\n+    }\n+    checkLoad(true);\n+  }\n+\n+  /**\n+   * Remove value with this key.\n+   * @param key key for deleting value\n+   * @return value, if it found with key or null if such value missing\n+   */\n+  public V remove(K key) {\n+    int[] hashAndIndex = computeHashAndIndex(key);\n+    int indexForRemoving = hashAndIndex[0];\n+    int hash = hashAndIndex[1];\n+    Node<K, V> previousNode = null;\n+    for (Node<K, V> e = table[indexForRemoving]; e != null; e = e.next) {\n+      if (hash == e.hash && (key == e.key || checkEquals(key, e.key))) {\n+        if (e.next == null && previousNode == null) {\n+          table[indexForRemoving] = null;\n+          size--;\n+          checkLoad(false);\n+          return e.value;\n+        } else {\n+          previousNode.next = null;\n+          size--;\n+          checkLoad(false);\n+          return e.value;\n+        }\n+      }\n+      previousNode = e;\n+    }\n+    return null;\n+  }\n+\n+  /**\n+   * Clear map from all elements.\n+   */\n+  public void clear() {\n+    for (int i = 0; i < table.length && size > 0; i++) {\n+      size = removeNextNode(table[i], size);\n+      table[i] = null;\n+    }\n+    table = (Node<K, V>[])new Node[INITIAL_CAPACITY];\n+  }\n+\n+  public int size() {\n+    return size;\n+  }\n+\n+  /**\n+   * Get value with help of key.\n+   * @param key key for searching value\n+   * @return found value or null, if value with key is missing\n+   */\n+  public V get(K key) {\n+    int[] hashAndIndex = computeHashAndIndex(key);\n+    int indexForGetting = hashAndIndex[0];","path":"src/com/homework5/MyHashMap.java","position":112,"original_position":112,"commit_id":"5f89617b46d53447c9f1f6f8fa7d80d58faa1af7","original_commit_id":"5f89617b46d53447c9f1f6f8fa7d80d58faa1af7","user":{"login":"Holubinka","id":46386175,"node_id":"MDQ6VXNlcjQ2Mzg2MTc1","avatar_url":"https://avatars0.githubusercontent.com/u/46386175?v=4","gravatar_id":"","url":"https://api.github.com/users/Holubinka","html_url":"https://github.com/Holubinka","followers_url":"https://api.github.com/users/Holubinka/followers","following_url":"https://api.github.com/users/Holubinka/following{/other_user}","gists_url":"https://api.github.com/users/Holubinka/gists{/gist_id}","starred_url":"https://api.github.com/users/Holubinka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Holubinka/subscriptions","organizations_url":"https://api.github.com/users/Holubinka/orgs","repos_url":"https://api.github.com/users/Holubinka/repos","events_url":"https://api.github.com/users/Holubinka/events{/privacy}","received_events_url":"https://api.github.com/users/Holubinka/received_events","type":"User","site_admin":false},"body":"Індекси поміняти місцями","created_at":"2019-04-03T14:05:43Z","updated_at":"2019-04-03T14:36:42Z","html_url":"https://github.com/serge29041996/MateAcademy/pull/6#discussion_r271759366","pull_request_url":"https://api.github.com/repos/serge29041996/MateAcademy/pulls/6","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/serge29041996/MateAcademy/pulls/comments/271759366"},"html":{"href":"https://github.com/serge29041996/MateAcademy/pull/6#discussion_r271759366"},"pull_request":{"href":"https://api.github.com/repos/serge29041996/MateAcademy/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/serge29041996/MateAcademy/pulls/6","id":266993073,"node_id":"MDExOlB1bGxSZXF1ZXN0MjY2OTkzMDcz","html_url":"https://github.com/serge29041996/MateAcademy/pull/6","diff_url":"https://github.com/serge29041996/MateAcademy/pull/6.diff","patch_url":"https://github.com/serge29041996/MateAcademy/pull/6.patch","issue_url":"https://api.github.com/repos/serge29041996/MateAcademy/issues/6","number":6,"state":"open","locked":false,"title":"Realization of Hash Map","user":{"login":"serge29041996","id":19746118,"node_id":"MDQ6VXNlcjE5NzQ2MTE4","avatar_url":"https://avatars0.githubusercontent.com/u/19746118?v=4","gravatar_id":"","url":"https://api.github.com/users/serge29041996","html_url":"https://github.com/serge29041996","followers_url":"https://api.github.com/users/serge29041996/followers","following_url":"https://api.github.com/users/serge29041996/following{/other_user}","gists_url":"https://api.github.com/users/serge29041996/gists{/gist_id}","starred_url":"https://api.github.com/users/serge29041996/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serge29041996/subscriptions","organizations_url":"https://api.github.com/users/serge29041996/orgs","repos_url":"https://api.github.com/users/serge29041996/repos","events_url":"https://api.github.com/users/serge29041996/events{/privacy}","received_events_url":"https://api.github.com/users/serge29041996/received_events","type":"User","site_admin":false},"body":"","created_at":"2019-04-03T10:54:28Z","updated_at":"2019-04-03T14:36:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c06dd121a11e6608b94627d58ef63d7aa77a8d4b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/serge29041996/MateAcademy/pulls/6/commits","review_comments_url":"https://api.github.com/repos/serge29041996/MateAcademy/pulls/6/comments","review_comment_url":"https://api.github.com/repos/serge29041996/MateAcademy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/serge29041996/MateAcademy/issues/6/comments","statuses_url":"https://api.github.com/repos/serge29041996/MateAcademy/statuses/5f89617b46d53447c9f1f6f8fa7d80d58faa1af7","head":{"label":"serge29041996:homework5","ref":"homework5","sha":"5f89617b46d53447c9f1f6f8fa7d80d58faa1af7","user":{"login":"serge29041996","id":19746118,"node_id":"MDQ6VXNlcjE5NzQ2MTE4","avatar_url":"https://avatars0.githubusercontent.com/u/19746118?v=4","gravatar_id":"","url":"https://api.github.com/users/serge29041996","html_url":"https://github.com/serge29041996","followers_url":"https://api.github.com/users/serge29041996/followers","following_url":"https://api.github.com/users/serge29041996/following{/other_user}","gists_url":"https://api.github.com/users/serge29041996/gists{/gist_id}","starred_url":"https://api.github.com/users/serge29041996/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serge29041996/subscriptions","organizations_url":"https://api.github.com/users/serge29041996/orgs","repos_url":"https://api.github.com/users/serge29041996/repos","events_url":"https://api.github.com/users/serge29041996/events{/privacy}","received_events_url":"https://api.github.com/users/serge29041996/received_events","type":"User","site_admin":false},"repo":{"id":177293110,"node_id":"MDEwOlJlcG9zaXRvcnkxNzcyOTMxMTA=","name":"MateAcademy","full_name":"serge29041996/MateAcademy","private":false,"owner":{"login":"serge29041996","id":19746118,"node_id":"MDQ6VXNlcjE5NzQ2MTE4","avatar_url":"https://avatars0.githubusercontent.com/u/19746118?v=4","gravatar_id":"","url":"https://api.github.com/users/serge29041996","html_url":"https://github.com/serge29041996","followers_url":"https://api.github.com/users/serge29041996/followers","following_url":"https://api.github.com/users/serge29041996/following{/other_user}","gists_url":"https://api.github.com/users/serge29041996/gists{/gist_id}","starred_url":"https://api.github.com/users/serge29041996/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serge29041996/subscriptions","organizations_url":"https://api.github.com/users/serge29041996/orgs","repos_url":"https://api.github.com/users/serge29041996/repos","events_url":"https://api.github.com/users/serge29041996/events{/privacy}","received_events_url":"https://api.github.com/users/serge29041996/received_events","type":"User","site_admin":false},"html_url":"https://github.com/serge29041996/MateAcademy","description":"Solution for tasks from mate.academy Java course","fork":false,"url":"https://api.github.com/repos/serge29041996/MateAcademy","forks_url":"https://api.github.com/repos/serge29041996/MateAcademy/forks","keys_url":"https://api.github.com/repos/serge29041996/MateAcademy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/serge29041996/MateAcademy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/serge29041996/MateAcademy/teams","hooks_url":"https://api.github.com/repos/serge29041996/MateAcademy/hooks","issue_events_url":"https://api.github.com/repos/serge29041996/MateAcademy/issues/events{/number}","events_url":"https://api.github.com/repos/serge29041996/MateAcademy/events","assignees_url":"https://api.github.com/repos/serge29041996/MateAcademy/assignees{/user}","branches_url":"https://api.github.com/repos/serge29041996/MateAcademy/branches{/branch}","tags_url":"https://api.github.com/repos/serge29041996/MateAcademy/tags","blobs_url":"https://api.github.com/repos/serge29041996/MateAcademy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/serge29041996/MateAcademy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/serge29041996/MateAcademy/git/refs{/sha}","trees_url":"https://api.github.com/repos/serge29041996/MateAcademy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/serge29041996/MateAcademy/statuses/{sha}","languages_url":"https://api.github.com/repos/serge29041996/MateAcademy/languages","stargazers_url":"https://api.github.com/repos/serge29041996/MateAcademy/stargazers","contributors_url":"https://api.github.com/repos/serge29041996/MateAcademy/contributors","subscribers_url":"https://api.github.com/repos/serge29041996/MateAcademy/subscribers","subscription_url":"https://api.github.com/repos/serge29041996/MateAcademy/subscription","commits_url":"https://api.github.com/repos/serge29041996/MateAcademy/commits{/sha}","git_commits_url":"https://api.github.com/repos/serge29041996/MateAcademy/git/commits{/sha}","comments_url":"https://api.github.com/repos/serge29041996/MateAcademy/comments{/number}","issue_comment_url":"https://api.github.com/repos/serge29041996/MateAcademy/issues/comments{/number}","contents_url":"https://api.github.com/repos/serge29041996/MateAcademy/contents/{+path}","compare_url":"https://api.github.com/repos/serge29041996/MateAcademy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/serge29041996/MateAcademy/merges","archive_url":"https://api.github.com/repos/serge29041996/MateAcademy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/serge29041996/MateAcademy/downloads","issues_url":"https://api.github.com/repos/serge29041996/MateAcademy/issues{/number}","pulls_url":"https://api.github.com/repos/serge29041996/MateAcademy/pulls{/number}","milestones_url":"https://api.github.com/repos/serge29041996/MateAcademy/milestones{/number}","notifications_url":"https://api.github.com/repos/serge29041996/MateAcademy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/serge29041996/MateAcademy/labels{/name}","releases_url":"https://api.github.com/repos/serge29041996/MateAcademy/releases{/id}","deployments_url":"https://api.github.com/repos/serge29041996/MateAcademy/deployments","created_at":"2019-03-23T13:35:45Z","updated_at":"2019-03-23T13:35:57Z","pushed_at":"2019-04-03T10:54:29Z","git_url":"git://github.com/serge29041996/MateAcademy.git","ssh_url":"git@github.com:serge29041996/MateAcademy.git","clone_url":"https://github.com/serge29041996/MateAcademy.git","svn_url":"https://github.com/serge29041996/MateAcademy","homepage":null,"size":32,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"serge29041996:master","ref":"master","sha":"a51014246507e55e748a65813b88087753b7f350","user":{"login":"serge29041996","id":19746118,"node_id":"MDQ6VXNlcjE5NzQ2MTE4","avatar_url":"https://avatars0.githubusercontent.com/u/19746118?v=4","gravatar_id":"","url":"https://api.github.com/users/serge29041996","html_url":"https://github.com/serge29041996","followers_url":"https://api.github.com/users/serge29041996/followers","following_url":"https://api.github.com/users/serge29041996/following{/other_user}","gists_url":"https://api.github.com/users/serge29041996/gists{/gist_id}","starred_url":"https://api.github.com/users/serge29041996/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serge29041996/subscriptions","organizations_url":"https://api.github.com/users/serge29041996/orgs","repos_url":"https://api.github.com/users/serge29041996/repos","events_url":"https://api.github.com/users/serge29041996/events{/privacy}","received_events_url":"https://api.github.com/users/serge29041996/received_events","type":"User","site_admin":false},"repo":{"id":177293110,"node_id":"MDEwOlJlcG9zaXRvcnkxNzcyOTMxMTA=","name":"MateAcademy","full_name":"serge29041996/MateAcademy","private":false,"owner":{"login":"serge29041996","id":19746118,"node_id":"MDQ6VXNlcjE5NzQ2MTE4","avatar_url":"https://avatars0.githubusercontent.com/u/19746118?v=4","gravatar_id":"","url":"https://api.github.com/users/serge29041996","html_url":"https://github.com/serge29041996","followers_url":"https://api.github.com/users/serge29041996/followers","following_url":"https://api.github.com/users/serge29041996/following{/other_user}","gists_url":"https://api.github.com/users/serge29041996/gists{/gist_id}","starred_url":"https://api.github.com/users/serge29041996/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serge29041996/subscriptions","organizations_url":"https://api.github.com/users/serge29041996/orgs","repos_url":"https://api.github.com/users/serge29041996/repos","events_url":"https://api.github.com/users/serge29041996/events{/privacy}","received_events_url":"https://api.github.com/users/serge29041996/received_events","type":"User","site_admin":false},"html_url":"https://github.com/serge29041996/MateAcademy","description":"Solution for tasks from mate.academy Java course","fork":false,"url":"https://api.github.com/repos/serge29041996/MateAcademy","forks_url":"https://api.github.com/repos/serge29041996/MateAcademy/forks","keys_url":"https://api.github.com/repos/serge29041996/MateAcademy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/serge29041996/MateAcademy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/serge29041996/MateAcademy/teams","hooks_url":"https://api.github.com/repos/serge29041996/MateAcademy/hooks","issue_events_url":"https://api.github.com/repos/serge29041996/MateAcademy/issues/events{/number}","events_url":"https://api.github.com/repos/serge29041996/MateAcademy/events","assignees_url":"https://api.github.com/repos/serge29041996/MateAcademy/assignees{/user}","branches_url":"https://api.github.com/repos/serge29041996/MateAcademy/branches{/branch}","tags_url":"https://api.github.com/repos/serge29041996/MateAcademy/tags","blobs_url":"https://api.github.com/repos/serge29041996/MateAcademy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/serge29041996/MateAcademy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/serge29041996/MateAcademy/git/refs{/sha}","trees_url":"https://api.github.com/repos/serge29041996/MateAcademy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/serge29041996/MateAcademy/statuses/{sha}","languages_url":"https://api.github.com/repos/serge29041996/MateAcademy/languages","stargazers_url":"https://api.github.com/repos/serge29041996/MateAcademy/stargazers","contributors_url":"https://api.github.com/repos/serge29041996/MateAcademy/contributors","subscribers_url":"https://api.github.com/repos/serge29041996/MateAcademy/subscribers","subscription_url":"https://api.github.com/repos/serge29041996/MateAcademy/subscription","commits_url":"https://api.github.com/repos/serge29041996/MateAcademy/commits{/sha}","git_commits_url":"https://api.github.com/repos/serge29041996/MateAcademy/git/commits{/sha}","comments_url":"https://api.github.com/repos/serge29041996/MateAcademy/comments{/number}","issue_comment_url":"https://api.github.com/repos/serge29041996/MateAcademy/issues/comments{/number}","contents_url":"https://api.github.com/repos/serge29041996/MateAcademy/contents/{+path}","compare_url":"https://api.github.com/repos/serge29041996/MateAcademy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/serge29041996/MateAcademy/merges","archive_url":"https://api.github.com/repos/serge29041996/MateAcademy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/serge29041996/MateAcademy/downloads","issues_url":"https://api.github.com/repos/serge29041996/MateAcademy/issues{/number}","pulls_url":"https://api.github.com/repos/serge29041996/MateAcademy/pulls{/number}","milestones_url":"https://api.github.com/repos/serge29041996/MateAcademy/milestones{/number}","notifications_url":"https://api.github.com/repos/serge29041996/MateAcademy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/serge29041996/MateAcademy/labels{/name}","releases_url":"https://api.github.com/repos/serge29041996/MateAcademy/releases{/id}","deployments_url":"https://api.github.com/repos/serge29041996/MateAcademy/deployments","created_at":"2019-03-23T13:35:45Z","updated_at":"2019-03-23T13:35:57Z","pushed_at":"2019-04-03T10:54:29Z","git_url":"git://github.com/serge29041996/MateAcademy.git","ssh_url":"git@github.com:serge29041996/MateAcademy.git","clone_url":"https://github.com/serge29041996/MateAcademy.git","svn_url":"https://github.com/serge29041996/MateAcademy","homepage":null,"size":32,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/serge29041996/MateAcademy/pulls/6"},"html":{"href":"https://github.com/serge29041996/MateAcademy/pull/6"},"issue":{"href":"https://api.github.com/repos/serge29041996/MateAcademy/issues/6"},"comments":{"href":"https://api.github.com/repos/serge29041996/MateAcademy/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/serge29041996/MateAcademy/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/serge29041996/MateAcademy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/serge29041996/MateAcademy/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/serge29041996/MateAcademy/statuses/5f89617b46d53447c9f1f6f8fa7d80d58faa1af7"}},"author_association":"OWNER"}}
{"actor":{"display_login":"Holubinka"}}