{"id":513,"date":"2020-02-03T21:51:01","date_gmt":"2020-02-03T13:51:01","guid":{"rendered":"https:\/\/www.caiqinyi.cn\/?p=513"},"modified":"2021-04-24T12:42:04","modified_gmt":"2021-04-24T04:42:04","slug":"annotation_style","status":"publish","type":"post","link":"https:\/\/www.caiqinyi.cn\/index.php\/2020\/02\/03\/annotation_style\/","title":{"rendered":"C++\u6ce8\u91ca\u98ce\u683c"},"content":{"rendered":"<p>\u6700\u8fd1\u8981\u7ed9\u4e4b\u524d\u505a\u7684\u52a8\u529b\u5b66\u9879\u76ee\u52a0\u4e0a\u6ce8\u91ca, \u5bfb\u601d\u7740\u6709\u6ca1\u6709\u4ec0\u4e48\u770b\u8d77\u6765\u6bd4\u8f83\u4f18\u96c5\u7684\u6ce8\u91ca\u98ce\u683c, \u5728\u817e\u8baf\u4e91\u793e\u533a\u627e\u5230\u4e00\u7bc7\u4e0d\u9519\u7684\u76f8\u5173\u6587\u7ae0, \u7279\u6b64\u63d0\u70bc\u603b\u7ed3\u4e00\u4e0b~<\/p>\n<p><!--more--><\/p>\n<p>\u53c2\u8003\u6587\u7ae0: <a href=\"https:\/\/cloud.tencent.com\/developer\/article\/1177513\">C++\u6ce8\u91ca\u98ce\u683c\u5efa\u8bae<\/a><\/p>\n<p>1. \u6587\u4ef6\u6ce8\u91ca\u793a\u4f8b<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\n\/\/\r\n\/\/@Copyright:Copyright 2018 Google Inc\r\n\/\/@License:GPL\r\n\/\/@Birth:created by Dablelv on 2018-08-02\r\n\/\/@Content:\u5f00\u6e90JSON\u89e3\u6790\u5e93\r\n\/\/@Version:1.1.1\r\n\/\/@Revision:last revised by lvlv on 2018-09-02\r\n\/\/\r\n<\/pre>\n<p>\u8fd9\u91cc\u63d0\u5230\u4e86Copyright\u548cLicense\u7684\u95ee\u9898, \u5206\u4eab\u4e00\u7bc7\u89e3\u91ca\u8fd9\u4e2a\u6bd4\u8f83\u901a\u4fd7\u6613\u61c2\u7684\u6587\u7ae0~ <a href=\"https:\/\/www.ruanyifeng.com\/blog\/2017\/10\/open-source-license-tutorial.html\">\u5f00\u6e90\u8bb8\u53ef\u8bc1\u6559\u7a0b<\/a><\/p>\n<p>2. \u7c7b\u6ce8\u91ca\u793a\u4f8b<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\n\/\/ Iterates over the contents of a GargantuanTable.\r\n\/\/ Example:\r\n\/\/    GargantuanTableIterator* iter = table->NewIterator();\r\n\/\/    for (iter->Seek(\"foo\"); !iter->done(); iter->Next()) \r\n\/\/    {\r\n\/\/      process(iter->key(), iter->value());\r\n\/\/    }\r\n\/\/    delete iter;\r\nclass GargantuanTableIterator\r\n{\r\n    ...\r\n};\r\n<\/pre>\n<p>3. \u51fd\u6570\u58f0\u660e\u6ce8\u91ca\u793a\u4f8b<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\n\/\/\r\n\/\/ @brief:\u83b7\u53d6\u5bb9\u5668\u8fed\u4ee3\u5668\r\n\/\/ @params:void\r\n\/\/ @ret:\u8fd4\u56de\u5bb9\u5668\u8fed\u4ee3\u5668\r\n\/\/ @birth:created by Dablelv on 20180802\r\n\/\/\r\nIterator* getIterator() const;\r\n<\/pre>\n<p>4. \u51fd\u6570\u5b9a\u4e49\u6ce8\u91ca\u793a\u4f8b<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\n\/\/ Divide result by two, taking into account that x contains the carry from the add.\r\nfor (int i = 0; i < result->size(); i++)\r\n{\r\n    x = (x << 8) + (*result)[i];\r\n    (*result)[i] = x >> 1;\r\n    x &= 1;\r\n}\r\n<\/pre>\n<p>\u6bd4\u8f83\u9690\u6666\u7684\u5730\u65b9\u8981\u5728\u884c\u5c3e\u52a0\u5165\u6ce8\u91ca, \u5728\u884c\u5c3e\u7a7a\u4e24\u683c\u6216\u4e00\u4e2aTab\u8fdb\u884c\u6ce8\u91ca. \u6bd4\u5982:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\nmmap_budget = max<int64>(0, mmap_budget - index_->length());\r\nif (mmap_budget >= data_size_ && !MmapData(mmap_chunk_bytes, mlock))\r\n{\r\n    return;  \/\/ Error already logged.\r\n}\r\n<\/pre>\n<p>\u524d\u540e\u76f8\u90bb\u51e0\u884c\u90fd\u6709\u6ce8\u91ca, \u53ef\u4ee5\u9002\u5f53\u8c03\u6574\u4f7f\u4e4b\u53ef\u8bfb\u6027\u66f4\u597d.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\n...\r\nDoSomething();                  \/\/ Comment here so the comments line up.\r\nDoSomethingElseThatIsLonger();  \/\/ Comment here so after two spaces\r\n...\r\n<\/pre>\n<p>5. \u7c7b\u6570\u636e\u6210\u5458\u6ce8\u91ca\u793a\u4f8b<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\nprivate:\r\n    \/\/Used to bounds-check table accesses. -1 means that we don't yet know how many entries the table has.\r\n    int num_total_entries_;\r\n<\/pre>\n<p>6. \u5168\u5c40\u53d8\u91cf\u6ce8\u91ca\u793a\u4f8b<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\n\/\/The total number of tests cases that we run through in this regression test.\r\nconst int kNumTestCases = 6;\r\n<\/pre>\n<p>7. TODO\u6ce8\u91ca\u793a\u4f8b<\/p>\n<p>\u5982\u679c\u9879\u76ee\u4e2d\u5b58\u5728\u529f\u80fd\u4ee3\u7801\u6709\u5f85\u4fee\u6539\u548c\u7f16\u5199\u5730\u65b9, \u5efa\u8bae\u4f7f\u7528TODO\u6ce8\u91ca\u8fdb\u884c\u7b80\u7565\u8bf4\u660e. TODO\u6ce8\u91ca\u7684\u4f5c\u7528\u7c7b\u4f3c\u4e8e\u4e66\u7b7e, \u4fbf\u4e8e\u5f00\u53d1\u8005\u5feb\u901f\u627e\u5230\u9700\u8981\u7ee7\u7eed\u5f00\u53d1\u7684\u4f4d\u7f6e\u548c\u6709\u5f85\u5b8c\u6210\u7684\u529f\u80fd, \u8d77\u5230\u63d0\u9192\u6807\u8bb0\u7684\u4f5c\u7528.<\/p>\n<p>TODO\u6ce8\u91ca\u8981\u4f7f\u7528\u5168\u5927\u5199\u7684\u5b57\u7b26\u4e32TODO, \u5728\u968f\u540e\u7684\u5706\u62ec\u53f7\u91cc\u5199\u4e0a\u8d1f\u8d23\u4eba\u7684\u540d\u5b57\u3001\u90ae\u4ef6\u5730\u5740\u3001bug ID\u6216\u5176\u5b83\u8eab\u4efd\u6807\u8bc6\u548c\u4e0e\u8fd9\u4e00TODO\u76f8\u5173\u7684\u95ee\u9898, \u4e3b\u8981\u76ee\u7684\u662f\u8ba9\u6dfb\u52a0\u6ce8\u91ca\u7684\u4eba\u6216\u8d1f\u8d23\u4eba\u53ef\u6839\u636e\u89c4\u8303\u7684TODO\u683c\u5f0f\u8fdb\u884c\u67e5\u627e. \u6dfb\u52a0TODO\u6ce8\u91ca\u4e00\u822c\u90fd\u662f\u5199\u4e0a\u81ea\u5df1\u7684\u540d\u5b57, \u4f46\u5e76\u4e0d\u610f\u5473\u7740\u4e00\u5b9a\u8981\u81ea\u5df1\u6765\u4fee\u6b63, \u9664\u975e\u81ea\u5df1\u662f\u8be5TODO\u6240\u63cf\u8ff0\u7684\u95ee\u9898\u7684\u8d1f\u8d23\u4eba.<br \/>\n\u7b80\u5355\u793a\u4f8b:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\n\/\/ TODO(kl@gmail.com): Use a \"*\" here for concatenation operator.\r\n\/\/ TODO(Zeke): change this to use relations.\r\n\/\/ TODO(bug 12345): remove the \"Last visitors\" feature\r\n<\/pre>\n<p>\u5982\u679c\u52a0TODO\u662f\u4e3a\u4e86\u5728\u201c\u5c06\u6765\u67d0\u4e00\u5929\u505a\u67d0\u4e8b\u201d, \u53ef\u4ee5\u9644\u4e0a\u4e00\u4e2a\u975e\u5e38\u660e\u786e\u7684\u65f6\u95f4\u201cFix by November 2005\u201d), \u6216\u8005\u4e00\u4e2a\u660e\u786e\u7684\u4e8b\u9879(\u201cRemove this code when all clients can handle XML responses.\u201d).<\/p>\n<p>8. \u5f03\u7528\u6ce8\u91ca\u793a\u4f8b<\/p>\n<p>\u901a\u8fc7\u5f03\u7528\u6ce8\u91ca(DEPRECATED comments) \u4ee5\u6807\u8bb0\u67d0\u63a5\u53e3\u70b9\u5df2\u5f03\u7528. \u53ef\u4ee5\u5199\u4e0a\u5305\u542b\u5168\u5927\u5199\u7684DEPRECATED\u7684\u6ce8\u91ca, \u4ee5\u6807\u8bb0\u67d0\u63a5\u53e3\u4e3a\u5f03\u7528\u72b6\u6001.<\/p>\n<p>\u5f03\u7528\u6ce8\u91ca\u5e94\u5f53\u5305\u6db5\u7b80\u77ed\u800c\u6e05\u6670\u7684\u6307\u5f15, \u4ee5\u5e2e\u52a9\u5176\u4ed6\u4eba\u4fee\u590d\u5176\u8c03\u7528\u70b9. \u5728C++\u4e2d, \u4f60\u53ef\u4ee5\u5c06\u4e00\u4e2a\u5f03\u7528\u51fd\u6570\u6539\u9020\u6210\u4e00\u4e2a\u5185\u8054\u51fd\u6570, \u8fd9\u4e00\u51fd\u6570\u5c06\u8c03\u7528\u65b0\u7684\u63a5\u53e3. \u5728DEPRECATED\u4e00\u8bcd\u540e, \u5728\u62ec\u53f7\u4e2d\u7559\u4e0b\u8d1f\u8d23\u4eba\u7684\u540d\u5b57\u3001\u90ae\u7bb1\u5730\u5740\u4ee5\u53ca\u5176\u4ed6\u8eab\u4efd\u6807\u8bc6. \u6ce8\u91ca\u53ef\u4ee5\u653e\u5728\u63a5\u53e3\u58f0\u660e\u524d, \u6216\u8005\u540c\u4e00\u884c. \u7b80\u5355\u793a\u4f8b\u5982\u4e0b:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\n\/\/DEPRECATED(dablelv):new interface changed to bool IsTableFull(const Table& t)\r\nbool IsTableFull();\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u8981\u7ed9\u4e4b\u524d\u505a\u7684\u52a8\u529b\u5b66\u9879\u76ee\u52a0\u4e0a\u6ce8\u91ca, \u5bfb\u601d\u7740\u6709\u6ca1\u6709\u4ec0\u4e48\u770b\u8d77\u6765\u6bd4\u8f83\u4f18\u96c5\u7684\u6ce8\u91ca\u98ce\u683c, \u5728\u817e\u8baf\u4e91\u793e\u533a\u627e\u5230\u4e00\u7bc7\u4e0d\u9519\u7684\u76f8 &hellip; <a href=\"https:\/\/www.caiqinyi.cn\/index.php\/2020\/02\/03\/annotation_style\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">C++\u6ce8\u91ca\u98ce\u683c<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/513"}],"collection":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/comments?post=513"}],"version-history":[{"count":6,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/513\/revisions"}],"predecessor-version":[{"id":516,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/513\/revisions\/516"}],"wp:attachment":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/media?parent=513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/categories?post=513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/tags?post=513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}