{"action":"created","comment":{"url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/pulls/comments/90131878","pull_request_review_id":10656200,"id":90131878,"diff_hunk":"@@ -0,0 +1,78 @@\n+package brainfuck;\n+\n+import java.util.Map;\n+import java.util.HashMap;\n+import java.util.Deque;\n+import java.util.ArrayDeque;\n+import java.util.Iterator;\n+\n+\n+import brainfuck.instructions.Instruction;\n+import brainfuck.instructions.Jump;\n+import brainfuck.instructions.Back;\n+import brainfuck.instructions.ConditionalJump;\n+import brainfuck.exceptions.InvalidInstructionException;\n+\n+/**\n+ * instructions from a List and execute them.\n+ *\n+ * @author Nassim Bounouas \n+ * @see Instruction\n+ */\n+public class JumpTable {\n+\t/**\n+\t * Hashmap from Jump to Back instructions \n+\t */\n+\tprivate Map<Integer, Integer> mapJumpToBack;\n+\t\n+\t/**\n+\t * Hashmap from Back to Jump instructions \n+\t */\n+\tprivate Map<Integer, Integer> mapBackToJump;\n+\n+\t/**\n+\t * Hashmap from Back to Jump instructions \n+\t */\n+\tprivate Deque<Integer> intermediateStack;\n+\n+\t/**\n+\t * Constructs an interpreter using the given List of Instruction.\n+\t *\n+\t * @param instructions \tList of Instruction containing instructions to execute.\n+\t */\n+\tpublic JumpTable() {\n+\t\tthis.mapJumpToBack = new HashMap<>();\n+\t\tthis.mapBackToJump = new HashMap<>();\n+\t\tthis.intermediateStack = new ArrayDeque<>();\n+\t}\n+\n+\tpublic void bind(Instruction i, int index) {\n+\t\tindex--; // Instruction list is counting from 1 to n and Machine from 0 to n\n+\t\tif (i instanceof Jump) {\n+\t\t\tthis.intermediateStack.push(new Integer(index));\n+\t\t}else if (i instanceof Back) {\n+\t\t\tInteger jumpIndex = this.intermediateStack.pop();\n+\t\t\tthis.mapJumpToBack.put(jumpIndex, new Integer(index));\n+\t\t\tthis.mapBackToJump.put(new Integer(index), jumpIndex);\n+\t\t}\n+\t}\n+\n+\tpublic Integer getJump(Instruction instr, int index) {\n+\t\tif (instr instanceof Jump) {\n+\t\t\treturn this.mapJumpToBack.get(new Integer(index));\n+\t\t} else if(instr instanceof Back) {\n+\t\t\treturn this.mapBackToJump.get(new Integer(index));\n+\t\t} else {\n+\t\t\tthrow new InvalidInstructionException(-1);\n+\t\t}\n+\t}\n+\t\n+\tpublic void showTable() {\n+\t\tIterator it = this.mapJumpToBack.entrySet().iterator();\n+\t\twhile (it.hasNext()) {\n+\t\t\tMap.Entry pair = (Map.Entry)it.next();\n+\t\t\tSystem.out.println(pair.getKey() + \" = \" + pair.getValue());\n+\t\t}\n+\t\tSystem.out.println(\"Size : \" + this.mapJumpToBack.size());\n+\t}","path":"src/brainfuck/JumpTable.java","position":77,"original_position":77,"commit_id":"259d345f0883734794bfa84dccb1f21b86d53c1a","original_commit_id":"259d345f0883734794bfa84dccb1f21b86d53c1a","user":{"login":"NassimBounouas","id":18635821,"avatar_url":"https://avatars.githubusercontent.com/u/18635821?v=3","gravatar_id":"","url":"https://api.github.com/users/NassimBounouas","html_url":"https://github.com/NassimBounouas","followers_url":"https://api.github.com/users/NassimBounouas/followers","following_url":"https://api.github.com/users/NassimBounouas/following{/other_user}","gists_url":"https://api.github.com/users/NassimBounouas/gists{/gist_id}","starred_url":"https://api.github.com/users/NassimBounouas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NassimBounouas/subscriptions","organizations_url":"https://api.github.com/users/NassimBounouas/orgs","repos_url":"https://api.github.com/users/NassimBounouas/repos","events_url":"https://api.github.com/users/NassimBounouas/events{/privacy}","received_events_url":"https://api.github.com/users/NassimBounouas/received_events","type":"User","site_admin":false},"body":"Changed","created_at":"2016-11-29T22:41:15Z","updated_at":"2016-11-29T22:41:15Z","html_url":"https://github.com/MIAOU-Polytech/BRAINF-CK_SI3/pull/55#discussion_r90131878","pull_request_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/pulls/55","_links":{"self":{"href":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/pulls/comments/90131878"},"html":{"href":"https://github.com/MIAOU-Polytech/BRAINF-CK_SI3/pull/55#discussion_r90131878"},"pull_request":{"href":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/pulls/55"}}},"pull_request":{"url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/pulls/55","id":94890828,"html_url":"https://github.com/MIAOU-Polytech/BRAINF-CK_SI3/pull/55","diff_url":"https://github.com/MIAOU-Polytech/BRAINF-CK_SI3/pull/55.diff","patch_url":"https://github.com/MIAOU-Polytech/BRAINF-CK_SI3/pull/55.patch","issue_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/issues/55","number":55,"state":"closed","locked":false,"title":"Jumptable system implemented","user":{"login":"NassimBounouas","id":18635821,"avatar_url":"https://avatars.githubusercontent.com/u/18635821?v=3","gravatar_id":"","url":"https://api.github.com/users/NassimBounouas","html_url":"https://github.com/NassimBounouas","followers_url":"https://api.github.com/users/NassimBounouas/followers","following_url":"https://api.github.com/users/NassimBounouas/following{/other_user}","gists_url":"https://api.github.com/users/NassimBounouas/gists{/gist_id}","starred_url":"https://api.github.com/users/NassimBounouas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NassimBounouas/subscriptions","organizations_url":"https://api.github.com/users/NassimBounouas/orgs","repos_url":"https://api.github.com/users/NassimBounouas/repos","events_url":"https://api.github.com/users/NassimBounouas/events{/privacy}","received_events_url":"https://api.github.com/users/NassimBounouas/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-22T20:21:33Z","updated_at":"2016-11-29T22:41:15Z","closed_at":"2016-11-23T12:44:53Z","merged_at":"2016-11-23T12:44:53Z","merge_commit_sha":"98132f2d11abb198d28048f5d9012748b647e994","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/pulls/55/commits","review_comments_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/pulls/55/comments","review_comment_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/issues/55/comments","statuses_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/statuses/259d345f0883734794bfa84dccb1f21b86d53c1a","head":{"label":"NassimBounouas:wip/JumpBack","ref":"wip/JumpBack","sha":"259d345f0883734794bfa84dccb1f21b86d53c1a","user":{"login":"NassimBounouas","id":18635821,"avatar_url":"https://avatars.githubusercontent.com/u/18635821?v=3","gravatar_id":"","url":"https://api.github.com/users/NassimBounouas","html_url":"https://github.com/NassimBounouas","followers_url":"https://api.github.com/users/NassimBounouas/followers","following_url":"https://api.github.com/users/NassimBounouas/following{/other_user}","gists_url":"https://api.github.com/users/NassimBounouas/gists{/gist_id}","starred_url":"https://api.github.com/users/NassimBounouas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NassimBounouas/subscriptions","organizations_url":"https://api.github.com/users/NassimBounouas/orgs","repos_url":"https://api.github.com/users/NassimBounouas/repos","events_url":"https://api.github.com/users/NassimBounouas/events{/privacy}","received_events_url":"https://api.github.com/users/NassimBounouas/received_events","type":"User","site_admin":false},"repo":{"id":71270702,"name":"BRAINF-CK_SI3","full_name":"NassimBounouas/BRAINF-CK_SI3","owner":{"login":"NassimBounouas","id":18635821,"avatar_url":"https://avatars.githubusercontent.com/u/18635821?v=3","gravatar_id":"","url":"https://api.github.com/users/NassimBounouas","html_url":"https://github.com/NassimBounouas","followers_url":"https://api.github.com/users/NassimBounouas/followers","following_url":"https://api.github.com/users/NassimBounouas/following{/other_user}","gists_url":"https://api.github.com/users/NassimBounouas/gists{/gist_id}","starred_url":"https://api.github.com/users/NassimBounouas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NassimBounouas/subscriptions","organizations_url":"https://api.github.com/users/NassimBounouas/orgs","repos_url":"https://api.github.com/users/NassimBounouas/repos","events_url":"https://api.github.com/users/NassimBounouas/events{/privacy}","received_events_url":"https://api.github.com/users/NassimBounouas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NassimBounouas/BRAINF-CK_SI3","description":null,"fork":true,"url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3","forks_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/forks","keys_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/teams","hooks_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/hooks","issue_events_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/issues/events{/number}","events_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/events","assignees_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/assignees{/user}","branches_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/branches{/branch}","tags_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/tags","blobs_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/git/refs{/sha}","trees_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/statuses/{sha}","languages_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/languages","stargazers_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/stargazers","contributors_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/contributors","subscribers_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/subscribers","subscription_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/subscription","commits_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/commits{/sha}","git_commits_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/git/commits{/sha}","comments_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/comments{/number}","issue_comment_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/issues/comments{/number}","contents_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/contents/{+path}","compare_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/merges","archive_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/downloads","issues_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/issues{/number}","pulls_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/pulls{/number}","milestones_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/milestones{/number}","notifications_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/labels{/name}","releases_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/releases{/id}","deployments_url":"https://api.github.com/repos/NassimBounouas/BRAINF-CK_SI3/deployments","created_at":"2016-10-18T16:54:33Z","updated_at":"2016-10-18T16:54:34Z","pushed_at":"2016-11-23T17:13:51Z","git_url":"git://github.com/NassimBounouas/BRAINF-CK_SI3.git","ssh_url":"git@github.com:NassimBounouas/BRAINF-CK_SI3.git","clone_url":"https://github.com/NassimBounouas/BRAINF-CK_SI3.git","svn_url":"https://github.com/NassimBounouas/BRAINF-CK_SI3","homepage":null,"size":426,"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":"MIAOU-Polytech:master","ref":"master","sha":"7bc2d8adc58ecf268129815aaf7bb48f598eaf39","user":{"login":"MIAOU-Polytech","id":22497997,"avatar_url":"https://avatars.githubusercontent.com/u/22497997?v=3","gravatar_id":"","url":"https://api.github.com/users/MIAOU-Polytech","html_url":"https://github.com/MIAOU-Polytech","followers_url":"https://api.github.com/users/MIAOU-Polytech/followers","following_url":"https://api.github.com/users/MIAOU-Polytech/following{/other_user}","gists_url":"https://api.github.com/users/MIAOU-Polytech/gists{/gist_id}","starred_url":"https://api.github.com/users/MIAOU-Polytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MIAOU-Polytech/subscriptions","organizations_url":"https://api.github.com/users/MIAOU-Polytech/orgs","repos_url":"https://api.github.com/users/MIAOU-Polytech/repos","events_url":"https://api.github.com/users/MIAOU-Polytech/events{/privacy}","received_events_url":"https://api.github.com/users/MIAOU-Polytech/received_events","type":"Organization","site_admin":false},"repo":{"id":69460342,"name":"BRAINF-CK_SI3","full_name":"MIAOU-Polytech/BRAINF-CK_SI3","owner":{"login":"MIAOU-Polytech","id":22497997,"avatar_url":"https://avatars.githubusercontent.com/u/22497997?v=3","gravatar_id":"","url":"https://api.github.com/users/MIAOU-Polytech","html_url":"https://github.com/MIAOU-Polytech","followers_url":"https://api.github.com/users/MIAOU-Polytech/followers","following_url":"https://api.github.com/users/MIAOU-Polytech/following{/other_user}","gists_url":"https://api.github.com/users/MIAOU-Polytech/gists{/gist_id}","starred_url":"https://api.github.com/users/MIAOU-Polytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MIAOU-Polytech/subscriptions","organizations_url":"https://api.github.com/users/MIAOU-Polytech/orgs","repos_url":"https://api.github.com/users/MIAOU-Polytech/repos","events_url":"https://api.github.com/users/MIAOU-Polytech/events{/privacy}","received_events_url":"https://api.github.com/users/MIAOU-Polytech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MIAOU-Polytech/BRAINF-CK_SI3","description":null,"fork":true,"url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3","forks_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/forks","keys_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/teams","hooks_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/hooks","issue_events_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/issues/events{/number}","events_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/events","assignees_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/assignees{/user}","branches_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/branches{/branch}","tags_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/tags","blobs_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/git/refs{/sha}","trees_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/statuses/{sha}","languages_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/languages","stargazers_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/stargazers","contributors_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/contributors","subscribers_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/subscribers","subscription_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/subscription","commits_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/commits{/sha}","git_commits_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/git/commits{/sha}","comments_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/comments{/number}","issue_comment_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/issues/comments{/number}","contents_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/contents/{+path}","compare_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/merges","archive_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/downloads","issues_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/issues{/number}","pulls_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/pulls{/number}","milestones_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/milestones{/number}","notifications_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/labels{/name}","releases_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/releases{/id}","deployments_url":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/deployments","created_at":"2016-09-28T12:20:54Z","updated_at":"2016-10-25T15:37:27Z","pushed_at":"2016-11-29T12:31:36Z","git_url":"git://github.com/MIAOU-Polytech/BRAINF-CK_SI3.git","ssh_url":"git@github.com:MIAOU-Polytech/BRAINF-CK_SI3.git","clone_url":"https://github.com/MIAOU-Polytech/BRAINF-CK_SI3.git","svn_url":"https://github.com/MIAOU-Polytech/BRAINF-CK_SI3","homepage":null,"size":2295,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/pulls/55"},"html":{"href":"https://github.com/MIAOU-Polytech/BRAINF-CK_SI3/pull/55"},"issue":{"href":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/issues/55"},"comments":{"href":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/issues/55/comments"},"review_comments":{"href":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/pulls/55/comments"},"review_comment":{"href":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/pulls/55/commits"},"statuses":{"href":"https://api.github.com/repos/MIAOU-Polytech/BRAINF-CK_SI3/statuses/259d345f0883734794bfa84dccb1f21b86d53c1a"}}}}
{"actor":{"display_login":"NassimBounouas"}}