{"action":"created","comment":{"url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/pulls/comments/215272492","pull_request_review_id":152496404,"id":215272492,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNTI3MjQ5Mg==","diff_hunk":"@@ -1,81 +1,287 @@\n+# -*- coding: utf-8 -*-\n \"\"\"\n-A classic (not left-leaning) Red-Black Tree implementation, supporting addition and deletion.\n+A classic (not left-leaning) Red-Black Tree implementation, supporting \n+addition and deletion. The code is by Stanislav Kozlovski, modified\n+slightly by George Flanagin of University of Richmond, with the purpose\n+of having it look somewhat more like the rest of the code at the\n+university. The changes are only additions.\n+\n+ 1. The color of the nodes is now an Enum.\n+ 2. The Node class contains __slots__ to save space.\n+ 3. For the purposes of teaching, I added a second iterator that\n+    prints the nodes of the tree with their connectivity.\n+ 4. There is a very tiny demo at the end of the file.\n+ 5. Also for the purposes of teaching about trees, I put in a type\n+    check to ensure all the Nodes in a tree are of the same\n+    value type.\n+ 6. I added two one-line @classmethods to build red and black\n+    nodes. This makes it easier (for me) to see when the two\n+    types of nodes are being built.\n+ 7. I added typing compatible with Python 3.6.\n+ 8. I added traceback and inspect to assist with debugging, \n+    again primarily as a teaching aid.\n+ 9. I added a __len__ operator to the tree to retun the number\n+    of Nodes, which conforms to standard practice.\n+10. I added a small number of boolean functions as an aid to \n+    teaching.\n+\n+Other than those changes, I left the code /in situ/.\n \"\"\"\n \n-# The possible Node colors\n-BLACK = 'BLACK'\n-RED = 'RED'\n-NIL = 'NIL'\n+import typing\n+from   typing import *\n+\n+import enum\n+import inspect\n+import traceback\n+\n+__author__ = 'Stanislav Kozlovski'\n+__copyright__ = 'Copyright 2018, Stanislavkozlovski'\n+__credits__ = None\n+__version__ = '1.1'\n+__maintainer__ = 'George Flanagin'\n+__email__ = 'gflanagin@richmond.edu'\n+__status__ = 'Production'\n+__required_version__ = 3.6\n+__license__ = 'MIT'\n+\n+class NODE_COLOR(enum.Enum):\n+    \"\"\"\n+    A red-black tree needs RED and BLACK, as well as the special\n+    colorless color that can be painted over, NIL.\n+    \"\"\"\n+    BLACK = 'BLACK'\n+    RED = 'RED'\n+    NIL = 'NIL'\n+\n+\n+\"\"\" For the purpose of forward references. \"\"\"\n+class Node:\n+    pass\n \n \n class Node:\n-    def __init__(self, value, color, parent, left=None, right=None):\n+    \"\"\"\n+    A tree is filled with nodes. This is a good use of\n+    __slots__ because there will probably be a great many\n+    Nodes in any useful Tree.\n+    \"\"\"\n+\n+    __slots__ = [ 'value', 'color', 'parent', 'left', 'right' ]\n+\n+    def __init__(self, value:Any, \n+        color:NODE_COLOR, \n+        parent: Node=None, \n+        left: Node =None, ","path":"rb_tree.py","position":81,"original_position":81,"commit_id":"585dfa01ddc537635baedbcb72693c88e6bce1bd","original_commit_id":"585dfa01ddc537635baedbcb72693c88e6bce1bd","user":{"login":"stanislavkozlovski","id":13639618,"node_id":"MDQ6VXNlcjEzNjM5NjE4","avatar_url":"https://avatars1.githubusercontent.com/u/13639618?v=4","gravatar_id":"","url":"https://api.github.com/users/stanislavkozlovski","html_url":"https://github.com/stanislavkozlovski","followers_url":"https://api.github.com/users/stanislavkozlovski/followers","following_url":"https://api.github.com/users/stanislavkozlovski/following{/other_user}","gists_url":"https://api.github.com/users/stanislavkozlovski/gists{/gist_id}","starred_url":"https://api.github.com/users/stanislavkozlovski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stanislavkozlovski/subscriptions","organizations_url":"https://api.github.com/users/stanislavkozlovski/orgs","repos_url":"https://api.github.com/users/stanislavkozlovski/repos","events_url":"https://api.github.com/users/stanislavkozlovski/events{/privacy}","received_events_url":"https://api.github.com/users/stanislavkozlovski/received_events","type":"User","site_admin":false},"body":"nit: there is spacing after Node here","created_at":"2018-09-05T13:38:59Z","updated_at":"2018-09-05T13:52:09Z","html_url":"https://github.com/stanislavkozlovski/Red-Black-Tree/pull/3#discussion_r215272492","pull_request_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/pulls/3","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/pulls/comments/215272492"},"html":{"href":"https://github.com/stanislavkozlovski/Red-Black-Tree/pull/3#discussion_r215272492"},"pull_request":{"href":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/pulls/3","id":212548540,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEyNTQ4NTQw","html_url":"https://github.com/stanislavkozlovski/Red-Black-Tree/pull/3","diff_url":"https://github.com/stanislavkozlovski/Red-Black-Tree/pull/3.diff","patch_url":"https://github.com/stanislavkozlovski/Red-Black-Tree/pull/3.patch","issue_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/issues/3","number":3,"state":"open","locked":false,"title":"Minor enhancements for teaching and learning about trees.","user":{"login":"georgeflanagin","id":2981739,"node_id":"MDQ6VXNlcjI5ODE3Mzk=","avatar_url":"https://avatars3.githubusercontent.com/u/2981739?v=4","gravatar_id":"","url":"https://api.github.com/users/georgeflanagin","html_url":"https://github.com/georgeflanagin","followers_url":"https://api.github.com/users/georgeflanagin/followers","following_url":"https://api.github.com/users/georgeflanagin/following{/other_user}","gists_url":"https://api.github.com/users/georgeflanagin/gists{/gist_id}","starred_url":"https://api.github.com/users/georgeflanagin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgeflanagin/subscriptions","organizations_url":"https://api.github.com/users/georgeflanagin/orgs","repos_url":"https://api.github.com/users/georgeflanagin/repos","events_url":"https://api.github.com/users/georgeflanagin/events{/privacy}","received_events_url":"https://api.github.com/users/georgeflanagin/received_events","type":"User","site_admin":false},"body":"The comments in the top of rb_tree.py cover the changes. \r\n\r\nI am an organizer of PyRVA.org, and I work at University of Richmond where I sometimes supply advice about Python programming.","created_at":"2018-09-01T14:13:03Z","updated_at":"2018-09-05T13:52:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"39dca9ac151ca2b2fec234ec1ea22b01b62dacc4","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/pulls/3/commits","review_comments_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/pulls/3/comments","review_comment_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/issues/3/comments","statuses_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/statuses/585dfa01ddc537635baedbcb72693c88e6bce1bd","head":{"label":"georgeflanagin:univ-richmond","ref":"univ-richmond","sha":"585dfa01ddc537635baedbcb72693c88e6bce1bd","user":{"login":"georgeflanagin","id":2981739,"node_id":"MDQ6VXNlcjI5ODE3Mzk=","avatar_url":"https://avatars3.githubusercontent.com/u/2981739?v=4","gravatar_id":"","url":"https://api.github.com/users/georgeflanagin","html_url":"https://github.com/georgeflanagin","followers_url":"https://api.github.com/users/georgeflanagin/followers","following_url":"https://api.github.com/users/georgeflanagin/following{/other_user}","gists_url":"https://api.github.com/users/georgeflanagin/gists{/gist_id}","starred_url":"https://api.github.com/users/georgeflanagin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgeflanagin/subscriptions","organizations_url":"https://api.github.com/users/georgeflanagin/orgs","repos_url":"https://api.github.com/users/georgeflanagin/repos","events_url":"https://api.github.com/users/georgeflanagin/events{/privacy}","received_events_url":"https://api.github.com/users/georgeflanagin/received_events","type":"User","site_admin":false},"repo":{"id":147003599,"node_id":"MDEwOlJlcG9zaXRvcnkxNDcwMDM1OTk=","name":"Red-Black-Tree-1","full_name":"georgeflanagin/Red-Black-Tree-1","owner":{"login":"georgeflanagin","id":2981739,"node_id":"MDQ6VXNlcjI5ODE3Mzk=","avatar_url":"https://avatars3.githubusercontent.com/u/2981739?v=4","gravatar_id":"","url":"https://api.github.com/users/georgeflanagin","html_url":"https://github.com/georgeflanagin","followers_url":"https://api.github.com/users/georgeflanagin/followers","following_url":"https://api.github.com/users/georgeflanagin/following{/other_user}","gists_url":"https://api.github.com/users/georgeflanagin/gists{/gist_id}","starred_url":"https://api.github.com/users/georgeflanagin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgeflanagin/subscriptions","organizations_url":"https://api.github.com/users/georgeflanagin/orgs","repos_url":"https://api.github.com/users/georgeflanagin/repos","events_url":"https://api.github.com/users/georgeflanagin/events{/privacy}","received_events_url":"https://api.github.com/users/georgeflanagin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/georgeflanagin/Red-Black-Tree-1","description":"An extremely well tested and commented red black tree implementation. Worth a look if you are studying the material.","fork":true,"url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1","forks_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/forks","keys_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/teams","hooks_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/hooks","issue_events_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/issues/events{/number}","events_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/events","assignees_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/assignees{/user}","branches_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/branches{/branch}","tags_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/tags","blobs_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/statuses/{sha}","languages_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/languages","stargazers_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/stargazers","contributors_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/contributors","subscribers_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/subscribers","subscription_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/subscription","commits_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/contents/{+path}","compare_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/merges","archive_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/downloads","issues_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/issues{/number}","pulls_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/pulls{/number}","milestones_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/milestones{/number}","notifications_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/labels{/name}","releases_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/releases{/id}","deployments_url":"https://api.github.com/repos/georgeflanagin/Red-Black-Tree-1/deployments","created_at":"2018-09-01T14:08:23Z","updated_at":"2018-09-01T14:08:25Z","pushed_at":"2018-09-01T14:10:16Z","git_url":"git://github.com/georgeflanagin/Red-Black-Tree-1.git","ssh_url":"git@github.com:georgeflanagin/Red-Black-Tree-1.git","clone_url":"https://github.com/georgeflanagin/Red-Black-Tree-1.git","svn_url":"https://github.com/georgeflanagin/Red-Black-Tree-1","homepage":null,"size":29,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"stanislavkozlovski:master","ref":"master","sha":"cb3cefb420bfa6c1d1fc703cefad54e209c7438c","user":{"login":"stanislavkozlovski","id":13639618,"node_id":"MDQ6VXNlcjEzNjM5NjE4","avatar_url":"https://avatars1.githubusercontent.com/u/13639618?v=4","gravatar_id":"","url":"https://api.github.com/users/stanislavkozlovski","html_url":"https://github.com/stanislavkozlovski","followers_url":"https://api.github.com/users/stanislavkozlovski/followers","following_url":"https://api.github.com/users/stanislavkozlovski/following{/other_user}","gists_url":"https://api.github.com/users/stanislavkozlovski/gists{/gist_id}","starred_url":"https://api.github.com/users/stanislavkozlovski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stanislavkozlovski/subscriptions","organizations_url":"https://api.github.com/users/stanislavkozlovski/orgs","repos_url":"https://api.github.com/users/stanislavkozlovski/repos","events_url":"https://api.github.com/users/stanislavkozlovski/events{/privacy}","received_events_url":"https://api.github.com/users/stanislavkozlovski/received_events","type":"User","site_admin":false},"repo":{"id":93428004,"node_id":"MDEwOlJlcG9zaXRvcnk5MzQyODAwNA==","name":"Red-Black-Tree","full_name":"stanislavkozlovski/Red-Black-Tree","owner":{"login":"stanislavkozlovski","id":13639618,"node_id":"MDQ6VXNlcjEzNjM5NjE4","avatar_url":"https://avatars1.githubusercontent.com/u/13639618?v=4","gravatar_id":"","url":"https://api.github.com/users/stanislavkozlovski","html_url":"https://github.com/stanislavkozlovski","followers_url":"https://api.github.com/users/stanislavkozlovski/followers","following_url":"https://api.github.com/users/stanislavkozlovski/following{/other_user}","gists_url":"https://api.github.com/users/stanislavkozlovski/gists{/gist_id}","starred_url":"https://api.github.com/users/stanislavkozlovski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stanislavkozlovski/subscriptions","organizations_url":"https://api.github.com/users/stanislavkozlovski/orgs","repos_url":"https://api.github.com/users/stanislavkozlovski/repos","events_url":"https://api.github.com/users/stanislavkozlovski/events{/privacy}","received_events_url":"https://api.github.com/users/stanislavkozlovski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/stanislavkozlovski/Red-Black-Tree","description":"An extremely well tested and commented red black tree implementation. Worth a look if you are studying the material.","fork":false,"url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree","forks_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/forks","keys_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/teams","hooks_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/hooks","issue_events_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/issues/events{/number}","events_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/events","assignees_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/assignees{/user}","branches_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/branches{/branch}","tags_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/tags","blobs_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/git/refs{/sha}","trees_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/statuses/{sha}","languages_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/languages","stargazers_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/stargazers","contributors_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/contributors","subscribers_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/subscribers","subscription_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/subscription","commits_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/commits{/sha}","git_commits_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/git/commits{/sha}","comments_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/comments{/number}","issue_comment_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/issues/comments{/number}","contents_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/contents/{+path}","compare_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/merges","archive_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/downloads","issues_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/issues{/number}","pulls_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/pulls{/number}","milestones_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/milestones{/number}","notifications_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/labels{/name}","releases_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/releases{/id}","deployments_url":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/deployments","created_at":"2017-06-05T17:08:59Z","updated_at":"2018-08-27T02:02:45Z","pushed_at":"2018-09-01T14:13:04Z","git_url":"git://github.com/stanislavkozlovski/Red-Black-Tree.git","ssh_url":"git@github.com:stanislavkozlovski/Red-Black-Tree.git","clone_url":"https://github.com/stanislavkozlovski/Red-Black-Tree.git","svn_url":"https://github.com/stanislavkozlovski/Red-Black-Tree","homepage":null,"size":24,"stargazers_count":48,"watchers_count":48,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":10,"open_issues":1,"watchers":48,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/pulls/3"},"html":{"href":"https://github.com/stanislavkozlovski/Red-Black-Tree/pull/3"},"issue":{"href":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/issues/3"},"comments":{"href":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/stanislavkozlovski/Red-Black-Tree/statuses/585dfa01ddc537635baedbcb72693c88e6bce1bd"}},"author_association":"NONE"}}
{"actor":{"display_login":"stanislavkozlovski"}}