GitHub PullRequestReviewCommentEvent at 2014-10-19 16:59:15
Repository: SInGe
Actor: baranov1ch
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/cscenter/SInGe/pulls/comments/19061515","id":19061515,"diff_hunk":"@@ -0,0 +1,121 @@\n+#include \"suffix_automata.hpp\"\n+#include <algorithm>\n+#include <cstdio>\n+#include <string>\n+\n+SuffixAutomata::SuffixAutomata() {\n+\tnode_pool_ = nullptr;\n+\tptr_in_node_pool_ = nullptr;\n+\troot_ = nullptr;\n+}\n+\n+int SuffixAutomata::amount_nodes() {\n+\treturn ptr_in_node_pool_ - node_pool_;\n+}\n+\n+int SuffixAutomata::get_id(Node* node) const {\n+\treturn node - node_pool_;\n+}\n+\n+Node* SuffixAutomata::get_node(int id) {\n+\treturn node_pool_ + id;\n+}\n+\n+Node* SuffixAutomata::new_node() {\n+\treturn ptr_in_node_pool_++;\n+}\n+\n+void SuffixAutomata::add_character(char c, int current_len, Node** last, int pos_last_stop_symbol) {\n+\tNode* node = new_node();\n+\tnode->r = current_len + 1;\n+\tnode->l = std::max(current_len - (*last)->len, pos_last_stop_symbol + 1);\n+\tnode->len = (*last)->len + 1;\n+\n+\tNode* p = *last;\n+\twhile (p) {\n+\t\tif  (!p->next.count(c)) {","path":"simple-SDCH-gen/suffix_automata.cpp","position":36,"original_position":36,"commit_id":"007d33fcb58d42d1341e235179b417cd5260cd87","original_commit_id":"007d33fcb58d42d1341e235179b417cd5260cd87","user":{"login":"baranov1ch","id":444371,"avatar_url":"https://avatars.githubusercontent.com/u/444371?v=2","gravatar_id":"","url":"https://api.github.com/users/baranov1ch","html_url":"https://github.com/baranov1ch","followers_url":"https://api.github.com/users/baranov1ch/followers","following_url":"https://api.github.com/users/baranov1ch/following{/other_user}","gists_url":"https://api.github.com/users/baranov1ch/gists{/gist_id}","starred_url":"https://api.github.com/users/baranov1ch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baranov1ch/subscriptions","organizations_url":"https://api.github.com/users/baranov1ch/orgs","repos_url":"https://api.github.com/users/baranov1ch/repos","events_url":"https://api.github.com/users/baranov1ch/events{/privacy}","received_events_url":"https://api.github.com/users/baranov1ch/received_events","type":"User","site_admin":false},"body":"кажется, что то, как делается в русской статье, более понятно.\r\nСначала находим узел с переходом в новое состояние, потом остальное.\r\n```\r\nSuffixAutomata::add_character(...) {\r\n  // используем placement конструктор на новой позиции\r\n  // last вполне себе может (и наверное должен семантически) быть полем автомата, а не аргументом.\r\n  // в конструкторе проставляем |link| в |root_|.\r\n  auto new_node = new (get_new_position()) Node(last_, stop_symbol_pos);\r\n  last_ = new_node;\r\n\r\n  // Для p и q по идее лучше бы сделать человеческие названия.\r\n  auto p = find_prev(last_, c);\r\n  if (p == root_)\r\n    return;\r\n  auto q = p->next[c];\r\n  if (q->len == p->len + 1) {\r\n    new_node->link = q;\r\n    last_ = new_node;\r\n    return;\r\n  }\r\n  auto clone = new (get_new_position()) Node(p, stop_symbol_pos);\r\n  clone->next = q->next;\r\n  clone->link = q->link;\r\n  // ну и так далее.\r\n  while (...) {\r\n    p->next[c] = clone;\r\n  }\r\n}\r\n\r\nКстати, возможно имеет смысл сделать итераторную обертку над `Node::link`, чтобы было меньше while)","created_at":"2014-10-19T16:59:15Z","updated_at":"2014-10-19T16:59:15Z","html_url":"https://github.com/cscenter/SInGe/pull/2#discussion_r19061515","pull_request_url":"https://api.github.com/repos/cscenter/SInGe/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/cscenter/SInGe/pulls/comments/19061515"},"html":{"href":"https://github.com/cscenter/SInGe/pull/2#discussion_r19061515"},"pull_request":{"href":"https://api.github.com/repos/cscenter/SInGe/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/cscenter/SInGe/pulls/2","id":22768919,"html_url":"https://github.com/cscenter/SInGe/pull/2","diff_url":"https://github.com/cscenter/SInGe/pull/2.diff","patch_url":"https://github.com/cscenter/SInGe/pull/2.patch","issue_url":"https://api.github.com/repos/cscenter/SInGe/issues/2","number":2,"state":"open","locked":false,"title":"Dictionary genetaror based on suffix automaton","user":{"login":"PavelSavchenkov","id":5619079,"avatar_url":"https://avatars.githubusercontent.com/u/5619079?v=2","gravatar_id":"","url":"https://api.github.com/users/PavelSavchenkov","html_url":"https://github.com/PavelSavchenkov","followers_url":"https://api.github.com/users/PavelSavchenkov/followers","following_url":"https://api.github.com/users/PavelSavchenkov/following{/other_user}","gists_url":"https://api.github.com/users/PavelSavchenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/PavelSavchenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PavelSavchenkov/subscriptions","organizations_url":"https://api.github.com/users/PavelSavchenkov/orgs","repos_url":"https://api.github.com/users/PavelSavchenkov/repos","events_url":"https://api.github.com/users/PavelSavchenkov/events{/privacy}","received_events_url":"https://api.github.com/users/PavelSavchenkov/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-10-15T08:55:11Z","updated_at":"2014-10-19T16:59:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ba4362c5c6e8e6cec6ea62c07afedd396f81846d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cscenter/SInGe/pulls/2/commits","review_comments_url":"https://api.github.com/repos/cscenter/SInGe/pulls/2/comments","review_comment_url":"https://api.github.com/repos/cscenter/SInGe/pulls/comments/{number}","comments_url":"https://api.github.com/repos/cscenter/SInGe/issues/2/comments","statuses_url":"https://api.github.com/repos/cscenter/SInGe/statuses/007d33fcb58d42d1341e235179b417cd5260cd87","head":{"label":"PavelSavchenkov:master","ref":"master","sha":"007d33fcb58d42d1341e235179b417cd5260cd87","user":{"login":"PavelSavchenkov","id":5619079,"avatar_url":"https://avatars.githubusercontent.com/u/5619079?v=2","gravatar_id":"","url":"https://api.github.com/users/PavelSavchenkov","html_url":"https://github.com/PavelSavchenkov","followers_url":"https://api.github.com/users/PavelSavchenkov/followers","following_url":"https://api.github.com/users/PavelSavchenkov/following{/other_user}","gists_url":"https://api.github.com/users/PavelSavchenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/PavelSavchenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PavelSavchenkov/subscriptions","organizations_url":"https://api.github.com/users/PavelSavchenkov/orgs","repos_url":"https://api.github.com/users/PavelSavchenkov/repos","events_url":"https://api.github.com/users/PavelSavchenkov/events{/privacy}","received_events_url":"https://api.github.com/users/PavelSavchenkov/received_events","type":"User","site_admin":false},"repo":{"id":25230138,"name":"SInGe","full_name":"PavelSavchenkov/SInGe","owner":{"login":"PavelSavchenkov","id":5619079,"avatar_url":"https://avatars.githubusercontent.com/u/5619079?v=2","gravatar_id":"","url":"https://api.github.com/users/PavelSavchenkov","html_url":"https://github.com/PavelSavchenkov","followers_url":"https://api.github.com/users/PavelSavchenkov/followers","following_url":"https://api.github.com/users/PavelSavchenkov/following{/other_user}","gists_url":"https://api.github.com/users/PavelSavchenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/PavelSavchenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PavelSavchenkov/subscriptions","organizations_url":"https://api.github.com/users/PavelSavchenkov/orgs","repos_url":"https://api.github.com/users/PavelSavchenkov/repos","events_url":"https://api.github.com/users/PavelSavchenkov/events{/privacy}","received_events_url":"https://api.github.com/users/PavelSavchenkov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PavelSavchenkov/SInGe","description":"","fork":true,"url":"https://api.github.com/repos/PavelSavchenkov/SInGe","forks_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/forks","keys_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/teams","hooks_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/hooks","issue_events_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/issues/events{/number}","events_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/events","assignees_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/assignees{/user}","branches_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/branches{/branch}","tags_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/tags","blobs_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/git/refs{/sha}","trees_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/statuses/{sha}","languages_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/languages","stargazers_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/stargazers","contributors_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/contributors","subscribers_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/subscribers","subscription_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/subscription","commits_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/commits{/sha}","git_commits_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/git/commits{/sha}","comments_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/comments{/number}","issue_comment_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/issues/comments/{number}","contents_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/contents/{+path}","compare_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/merges","archive_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/downloads","issues_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/issues{/number}","pulls_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/pulls{/number}","milestones_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/milestones{/number}","notifications_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/labels{/name}","releases_url":"https://api.github.com/repos/PavelSavchenkov/SInGe/releases{/id}","created_at":"2014-10-14T22:59:15Z","updated_at":"2014-10-15T08:53:37Z","pushed_at":"2014-10-15T08:53:37Z","git_url":"git://github.com/PavelSavchenkov/SInGe.git","ssh_url":"git@github.com:PavelSavchenkov/SInGe.git","clone_url":"https://github.com/PavelSavchenkov/SInGe.git","svn_url":"https://github.com/PavelSavchenkov/SInGe","homepage":null,"size":374,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"cscenter:master","ref":"master","sha":"1855709b5cc5d3fd443c284875f9413a6f3808d8","user":{"login":"cscenter","id":5622041,"avatar_url":"https://avatars.githubusercontent.com/u/5622041?v=2","gravatar_id":"","url":"https://api.github.com/users/cscenter","html_url":"https://github.com/cscenter","followers_url":"https://api.github.com/users/cscenter/followers","following_url":"https://api.github.com/users/cscenter/following{/other_user}","gists_url":"https://api.github.com/users/cscenter/gists{/gist_id}","starred_url":"https://api.github.com/users/cscenter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cscenter/subscriptions","organizations_url":"https://api.github.com/users/cscenter/orgs","repos_url":"https://api.github.com/users/cscenter/repos","events_url":"https://api.github.com/users/cscenter/events{/privacy}","received_events_url":"https://api.github.com/users/cscenter/received_events","type":"Organization","site_admin":false},"repo":{"id":24676947,"name":"SInGe","full_name":"cscenter/SInGe","owner":{"login":"cscenter","id":5622041,"avatar_url":"https://avatars.githubusercontent.com/u/5622041?v=2","gravatar_id":"","url":"https://api.github.com/users/cscenter","html_url":"https://github.com/cscenter","followers_url":"https://api.github.com/users/cscenter/followers","following_url":"https://api.github.com/users/cscenter/following{/other_user}","gists_url":"https://api.github.com/users/cscenter/gists{/gist_id}","starred_url":"https://api.github.com/users/cscenter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cscenter/subscriptions","organizations_url":"https://api.github.com/users/cscenter/orgs","repos_url":"https://api.github.com/users/cscenter/repos","events_url":"https://api.github.com/users/cscenter/events{/privacy}","received_events_url":"https://api.github.com/users/cscenter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cscenter/SInGe","description":"","fork":false,"url":"https://api.github.com/repos/cscenter/SInGe","forks_url":"https://api.github.com/repos/cscenter/SInGe/forks","keys_url":"https://api.github.com/repos/cscenter/SInGe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cscenter/SInGe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cscenter/SInGe/teams","hooks_url":"https://api.github.com/repos/cscenter/SInGe/hooks","issue_events_url":"https://api.github.com/repos/cscenter/SInGe/issues/events{/number}","events_url":"https://api.github.com/repos/cscenter/SInGe/events","assignees_url":"https://api.github.com/repos/cscenter/SInGe/assignees{/user}","branches_url":"https://api.github.com/repos/cscenter/SInGe/branches{/branch}","tags_url":"https://api.github.com/repos/cscenter/SInGe/tags","blobs_url":"https://api.github.com/repos/cscenter/SInGe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cscenter/SInGe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cscenter/SInGe/git/refs{/sha}","trees_url":"https://api.github.com/repos/cscenter/SInGe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cscenter/SInGe/statuses/{sha}","languages_url":"https://api.github.com/repos/cscenter/SInGe/languages","stargazers_url":"https://api.github.com/repos/cscenter/SInGe/stargazers","contributors_url":"https://api.github.com/repos/cscenter/SInGe/contributors","subscribers_url":"https://api.github.com/repos/cscenter/SInGe/subscribers","subscription_url":"https://api.github.com/repos/cscenter/SInGe/subscription","commits_url":"https://api.github.com/repos/cscenter/SInGe/commits{/sha}","git_commits_url":"https://api.github.com/repos/cscenter/SInGe/git/commits{/sha}","comments_url":"https://api.github.com/repos/cscenter/SInGe/comments{/number}","issue_comment_url":"https://api.github.com/repos/cscenter/SInGe/issues/comments/{number}","contents_url":"https://api.github.com/repos/cscenter/SInGe/contents/{+path}","compare_url":"https://api.github.com/repos/cscenter/SInGe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cscenter/SInGe/merges","archive_url":"https://api.github.com/repos/cscenter/SInGe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cscenter/SInGe/downloads","issues_url":"https://api.github.com/repos/cscenter/SInGe/issues{/number}","pulls_url":"https://api.github.com/repos/cscenter/SInGe/pulls{/number}","milestones_url":"https://api.github.com/repos/cscenter/SInGe/milestones{/number}","notifications_url":"https://api.github.com/repos/cscenter/SInGe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cscenter/SInGe/labels{/name}","releases_url":"https://api.github.com/repos/cscenter/SInGe/releases{/id}","created_at":"2014-10-01T12:07:01Z","updated_at":"2014-10-13T18:06:02Z","pushed_at":"2014-10-09T11:36:36Z","git_url":"git://github.com/cscenter/SInGe.git","ssh_url":"git@github.com:cscenter/SInGe.git","clone_url":"https://github.com/cscenter/SInGe.git","svn_url":"https://github.com/cscenter/SInGe","homepage":null,"size":112,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cscenter/SInGe/pulls/2"},"html":{"href":"https://github.com/cscenter/SInGe/pull/2"},"issue":{"href":"https://api.github.com/repos/cscenter/SInGe/issues/2"},"comments":{"href":"https://api.github.com/repos/cscenter/SInGe/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/cscenter/SInGe/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/cscenter/SInGe/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/cscenter/SInGe/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/cscenter/SInGe/statuses/007d33fcb58d42d1341e235179b417cd5260cd87"}}}}