{"action":"created","comment":{"url":"https://api.github.com/repos/Bl41r/data-structures/pulls/comments/77409072","id":77409072,"diff_hunk":"@@ -0,0 +1,91 @@\n+# -*- coding: utf-8 -*-\n+\"\"\"This is a module for a binary heap.\n+\n+It uses a list to maintain the values and their relationships.  Use push\n+to insert a value into the heap, and pop to remove and return the root.\n+\"\"\"\n+\n+\n+class MinHeap(object):\n+    \"\"\"Min heap class with push and pop methods.\"\"\"\n+\n+    def __init__(self, heap=None):\n+        \"\"\"Initialize the heap with optional heap(list) of integers.\"\"\"\n+        if type(heap) is not list and heap is not None:\n+            raise TypeError('Heap argument must be list type.')\n+\n+        if heap is None:\n+            self.heap = []\n+        else:\n+            self.heap = heap\n+\n+        try:\n+            self.heap = sorted(self.heap)\n+        except (ValueError, TypeError):\n+            raise TypeError('Heap must contain only integers.')\n+\n+    def __repr__(self):\n+        \"\"\"Display the heap in list form.\"\"\"\n+        return repr(self.heap)\n+\n+    # Internal methods\n+    def _swap(self, a, b):\n+        \"\"\"Swap 2 values in heap.\"\"\"\n+        self.heap[a], self.heap[b] = self.heap[b], self.heap[a]\n+\n+    def _parent_index(self, child_idx):\n+        \"\"\"Return index of parent. Negative 1 indicates idx is root.\"\"\"\n+        return ((child_idx - 1) // 2)\n+\n+    def _min_child(self, parent_idx):\n+        \"\"\"Return index of min child value.\"\"\"\n+        left_index = 2 * parent_idx + 1\n+        try:\n+            left = self.heap[left_index]\n+        except IndexError:\n+            return None\n+\n+        try:\n+            right = self.heap[left_index + 1]\n+        except IndexError:\n+            return left_index\n+\n+        if left < right:\n+            return left_index\n+        if right <= left:\n+            return left_index + 1\n+\n+    # User methods\n+    def push(self, val):\n+        \"\"\"Push an integer onto the heap.\"\"\"\n+        if isinstance(val, int):","path":"src/binheap.py","position":61,"original_position":61,"commit_id":"1c5d26a1dbd3bca62ccf4249740d983f65c1fae8","original_commit_id":"1c5d26a1dbd3bca62ccf4249740d983f65c1fae8","user":{"login":"WillWeatherford","id":7210312,"avatar_url":"https://avatars.githubusercontent.com/u/7210312?v=3","gravatar_id":"","url":"https://api.github.com/users/WillWeatherford","html_url":"https://github.com/WillWeatherford","followers_url":"https://api.github.com/users/WillWeatherford/followers","following_url":"https://api.github.com/users/WillWeatherford/following{/other_user}","gists_url":"https://api.github.com/users/WillWeatherford/gists{/gist_id}","starred_url":"https://api.github.com/users/WillWeatherford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WillWeatherford/subscriptions","organizations_url":"https://api.github.com/users/WillWeatherford/orgs","repos_url":"https://api.github.com/users/WillWeatherford/repos","events_url":"https://api.github.com/users/WillWeatherford/events{/privacy}","received_events_url":"https://api.github.com/users/WillWeatherford/received_events","type":"User","site_admin":false},"body":"If you guys didn't have this type check, you could just use your Heap as the basis for your Priority Queue, by passing tuples (which are comparable and therefore sortable) into the heap.","created_at":"2016-09-02T20:43:35Z","updated_at":"2016-09-02T20:43:35Z","html_url":"https://github.com/Bl41r/data-structures/pull/9#discussion_r77409072","pull_request_url":"https://api.github.com/repos/Bl41r/data-structures/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/Bl41r/data-structures/pulls/comments/77409072"},"html":{"href":"https://github.com/Bl41r/data-structures/pull/9#discussion_r77409072"},"pull_request":{"href":"https://api.github.com/repos/Bl41r/data-structures/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/Bl41r/data-structures/pulls/9","id":83102035,"html_url":"https://github.com/Bl41r/data-structures/pull/9","diff_url":"https://github.com/Bl41r/data-structures/pull/9.diff","patch_url":"https://github.com/Bl41r/data-structures/pull/9.patch","issue_url":"https://api.github.com/repos/Bl41r/data-structures/issues/9","number":9,"state":"open","locked":false,"title":"Priorityq","user":{"login":"Bl41r","id":18507197,"avatar_url":"https://avatars.githubusercontent.com/u/18507197?v=3","gravatar_id":"","url":"https://api.github.com/users/Bl41r","html_url":"https://github.com/Bl41r","followers_url":"https://api.github.com/users/Bl41r/followers","following_url":"https://api.github.com/users/Bl41r/following{/other_user}","gists_url":"https://api.github.com/users/Bl41r/gists{/gist_id}","starred_url":"https://api.github.com/users/Bl41r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bl41r/subscriptions","organizations_url":"https://api.github.com/users/Bl41r/orgs","repos_url":"https://api.github.com/users/Bl41r/repos","events_url":"https://api.github.com/users/Bl41r/events{/privacy}","received_events_url":"https://api.github.com/users/Bl41r/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-08-29T13:49:37Z","updated_at":"2016-09-02T20:43:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"79e3b5b5a4886084291354641a269ee8c8dae59b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Bl41r/data-structures/pulls/9/commits","review_comments_url":"https://api.github.com/repos/Bl41r/data-structures/pulls/9/comments","review_comment_url":"https://api.github.com/repos/Bl41r/data-structures/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Bl41r/data-structures/issues/9/comments","statuses_url":"https://api.github.com/repos/Bl41r/data-structures/statuses/1c5d26a1dbd3bca62ccf4249740d983f65c1fae8","head":{"label":"Bl41r:priorityq","ref":"priorityq","sha":"1c5d26a1dbd3bca62ccf4249740d983f65c1fae8","user":{"login":"Bl41r","id":18507197,"avatar_url":"https://avatars.githubusercontent.com/u/18507197?v=3","gravatar_id":"","url":"https://api.github.com/users/Bl41r","html_url":"https://github.com/Bl41r","followers_url":"https://api.github.com/users/Bl41r/followers","following_url":"https://api.github.com/users/Bl41r/following{/other_user}","gists_url":"https://api.github.com/users/Bl41r/gists{/gist_id}","starred_url":"https://api.github.com/users/Bl41r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bl41r/subscriptions","organizations_url":"https://api.github.com/users/Bl41r/orgs","repos_url":"https://api.github.com/users/Bl41r/repos","events_url":"https://api.github.com/users/Bl41r/events{/privacy}","received_events_url":"https://api.github.com/users/Bl41r/received_events","type":"User","site_admin":false},"repo":{"id":65763652,"name":"data-structures","full_name":"Bl41r/data-structures","owner":{"login":"Bl41r","id":18507197,"avatar_url":"https://avatars.githubusercontent.com/u/18507197?v=3","gravatar_id":"","url":"https://api.github.com/users/Bl41r","html_url":"https://github.com/Bl41r","followers_url":"https://api.github.com/users/Bl41r/followers","following_url":"https://api.github.com/users/Bl41r/following{/other_user}","gists_url":"https://api.github.com/users/Bl41r/gists{/gist_id}","starred_url":"https://api.github.com/users/Bl41r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bl41r/subscriptions","organizations_url":"https://api.github.com/users/Bl41r/orgs","repos_url":"https://api.github.com/users/Bl41r/repos","events_url":"https://api.github.com/users/Bl41r/events{/privacy}","received_events_url":"https://api.github.com/users/Bl41r/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Bl41r/data-structures","description":"Repo that holds implementations of a variety of data structures","fork":false,"url":"https://api.github.com/repos/Bl41r/data-structures","forks_url":"https://api.github.com/repos/Bl41r/data-structures/forks","keys_url":"https://api.github.com/repos/Bl41r/data-structures/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Bl41r/data-structures/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Bl41r/data-structures/teams","hooks_url":"https://api.github.com/repos/Bl41r/data-structures/hooks","issue_events_url":"https://api.github.com/repos/Bl41r/data-structures/issues/events{/number}","events_url":"https://api.github.com/repos/Bl41r/data-structures/events","assignees_url":"https://api.github.com/repos/Bl41r/data-structures/assignees{/user}","branches_url":"https://api.github.com/repos/Bl41r/data-structures/branches{/branch}","tags_url":"https://api.github.com/repos/Bl41r/data-structures/tags","blobs_url":"https://api.github.com/repos/Bl41r/data-structures/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Bl41r/data-structures/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Bl41r/data-structures/git/refs{/sha}","trees_url":"https://api.github.com/repos/Bl41r/data-structures/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Bl41r/data-structures/statuses/{sha}","languages_url":"https://api.github.com/repos/Bl41r/data-structures/languages","stargazers_url":"https://api.github.com/repos/Bl41r/data-structures/stargazers","contributors_url":"https://api.github.com/repos/Bl41r/data-structures/contributors","subscribers_url":"https://api.github.com/repos/Bl41r/data-structures/subscribers","subscription_url":"https://api.github.com/repos/Bl41r/data-structures/subscription","commits_url":"https://api.github.com/repos/Bl41r/data-structures/commits{/sha}","git_commits_url":"https://api.github.com/repos/Bl41r/data-structures/git/commits{/sha}","comments_url":"https://api.github.com/repos/Bl41r/data-structures/comments{/number}","issue_comment_url":"https://api.github.com/repos/Bl41r/data-structures/issues/comments{/number}","contents_url":"https://api.github.com/repos/Bl41r/data-structures/contents/{+path}","compare_url":"https://api.github.com/repos/Bl41r/data-structures/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Bl41r/data-structures/merges","archive_url":"https://api.github.com/repos/Bl41r/data-structures/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Bl41r/data-structures/downloads","issues_url":"https://api.github.com/repos/Bl41r/data-structures/issues{/number}","pulls_url":"https://api.github.com/repos/Bl41r/data-structures/pulls{/number}","milestones_url":"https://api.github.com/repos/Bl41r/data-structures/milestones{/number}","notifications_url":"https://api.github.com/repos/Bl41r/data-structures/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Bl41r/data-structures/labels{/name}","releases_url":"https://api.github.com/repos/Bl41r/data-structures/releases{/id}","deployments_url":"https://api.github.com/repos/Bl41r/data-structures/deployments","created_at":"2016-08-15T20:42:39Z","updated_at":"2016-08-15T20:42:39Z","pushed_at":"2016-09-02T07:04:46Z","git_url":"git://github.com/Bl41r/data-structures.git","ssh_url":"git@github.com:Bl41r/data-structures.git","clone_url":"https://github.com/Bl41r/data-structures.git","svn_url":"https://github.com/Bl41r/data-structures","homepage":null,"size":141,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":0,"default_branch":"master"}},"base":{"label":"Bl41r:master","ref":"master","sha":"6cbb45c40b14297c650af28ab39df8bd92fe6d2f","user":{"login":"Bl41r","id":18507197,"avatar_url":"https://avatars.githubusercontent.com/u/18507197?v=3","gravatar_id":"","url":"https://api.github.com/users/Bl41r","html_url":"https://github.com/Bl41r","followers_url":"https://api.github.com/users/Bl41r/followers","following_url":"https://api.github.com/users/Bl41r/following{/other_user}","gists_url":"https://api.github.com/users/Bl41r/gists{/gist_id}","starred_url":"https://api.github.com/users/Bl41r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bl41r/subscriptions","organizations_url":"https://api.github.com/users/Bl41r/orgs","repos_url":"https://api.github.com/users/Bl41r/repos","events_url":"https://api.github.com/users/Bl41r/events{/privacy}","received_events_url":"https://api.github.com/users/Bl41r/received_events","type":"User","site_admin":false},"repo":{"id":65763652,"name":"data-structures","full_name":"Bl41r/data-structures","owner":{"login":"Bl41r","id":18507197,"avatar_url":"https://avatars.githubusercontent.com/u/18507197?v=3","gravatar_id":"","url":"https://api.github.com/users/Bl41r","html_url":"https://github.com/Bl41r","followers_url":"https://api.github.com/users/Bl41r/followers","following_url":"https://api.github.com/users/Bl41r/following{/other_user}","gists_url":"https://api.github.com/users/Bl41r/gists{/gist_id}","starred_url":"https://api.github.com/users/Bl41r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bl41r/subscriptions","organizations_url":"https://api.github.com/users/Bl41r/orgs","repos_url":"https://api.github.com/users/Bl41r/repos","events_url":"https://api.github.com/users/Bl41r/events{/privacy}","received_events_url":"https://api.github.com/users/Bl41r/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Bl41r/data-structures","description":"Repo that holds implementations of a variety of data structures","fork":false,"url":"https://api.github.com/repos/Bl41r/data-structures","forks_url":"https://api.github.com/repos/Bl41r/data-structures/forks","keys_url":"https://api.github.com/repos/Bl41r/data-structures/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Bl41r/data-structures/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Bl41r/data-structures/teams","hooks_url":"https://api.github.com/repos/Bl41r/data-structures/hooks","issue_events_url":"https://api.github.com/repos/Bl41r/data-structures/issues/events{/number}","events_url":"https://api.github.com/repos/Bl41r/data-structures/events","assignees_url":"https://api.github.com/repos/Bl41r/data-structures/assignees{/user}","branches_url":"https://api.github.com/repos/Bl41r/data-structures/branches{/branch}","tags_url":"https://api.github.com/repos/Bl41r/data-structures/tags","blobs_url":"https://api.github.com/repos/Bl41r/data-structures/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Bl41r/data-structures/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Bl41r/data-structures/git/refs{/sha}","trees_url":"https://api.github.com/repos/Bl41r/data-structures/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Bl41r/data-structures/statuses/{sha}","languages_url":"https://api.github.com/repos/Bl41r/data-structures/languages","stargazers_url":"https://api.github.com/repos/Bl41r/data-structures/stargazers","contributors_url":"https://api.github.com/repos/Bl41r/data-structures/contributors","subscribers_url":"https://api.github.com/repos/Bl41r/data-structures/subscribers","subscription_url":"https://api.github.com/repos/Bl41r/data-structures/subscription","commits_url":"https://api.github.com/repos/Bl41r/data-structures/commits{/sha}","git_commits_url":"https://api.github.com/repos/Bl41r/data-structures/git/commits{/sha}","comments_url":"https://api.github.com/repos/Bl41r/data-structures/comments{/number}","issue_comment_url":"https://api.github.com/repos/Bl41r/data-structures/issues/comments{/number}","contents_url":"https://api.github.com/repos/Bl41r/data-structures/contents/{+path}","compare_url":"https://api.github.com/repos/Bl41r/data-structures/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Bl41r/data-structures/merges","archive_url":"https://api.github.com/repos/Bl41r/data-structures/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Bl41r/data-structures/downloads","issues_url":"https://api.github.com/repos/Bl41r/data-structures/issues{/number}","pulls_url":"https://api.github.com/repos/Bl41r/data-structures/pulls{/number}","milestones_url":"https://api.github.com/repos/Bl41r/data-structures/milestones{/number}","notifications_url":"https://api.github.com/repos/Bl41r/data-structures/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Bl41r/data-structures/labels{/name}","releases_url":"https://api.github.com/repos/Bl41r/data-structures/releases{/id}","deployments_url":"https://api.github.com/repos/Bl41r/data-structures/deployments","created_at":"2016-08-15T20:42:39Z","updated_at":"2016-08-15T20:42:39Z","pushed_at":"2016-09-02T07:04:46Z","git_url":"git://github.com/Bl41r/data-structures.git","ssh_url":"git@github.com:Bl41r/data-structures.git","clone_url":"https://github.com/Bl41r/data-structures.git","svn_url":"https://github.com/Bl41r/data-structures","homepage":null,"size":141,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Bl41r/data-structures/pulls/9"},"html":{"href":"https://github.com/Bl41r/data-structures/pull/9"},"issue":{"href":"https://api.github.com/repos/Bl41r/data-structures/issues/9"},"comments":{"href":"https://api.github.com/repos/Bl41r/data-structures/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/Bl41r/data-structures/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/Bl41r/data-structures/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Bl41r/data-structures/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/Bl41r/data-structures/statuses/1c5d26a1dbd3bca62ccf4249740d983f65c1fae8"}}}}
{"actor":{"display_login":"WillWeatherford"}}