{"id":1950,"date":"2009-10-04T15:02:32","date_gmt":"2009-10-04T07:02:32","guid":{"rendered":"https:\/\/lifeparty.idv.tw\/blog\/?p=1950"},"modified":"2009-10-04T15:08:33","modified_gmt":"2009-10-04T07:08:33","slug":"%e5%ad%97%e5%85%83%e4%b8%b2%e5%88%97%e5%b8%b8%e6%95%b8%e7%9a%84%e7%b4%a2%e5%bc%95%e9%8d%b5%e5%80%bc","status":"publish","type":"post","link":"https:\/\/lifeparty.idv.tw\/blog\/archives\/1950","title":{"rendered":"\u4ee5\u5b57\u5143\u4e32\u5217\u5e38\u6578\u7576\u7d22\u5f15\u9375\u503c"},"content":{"rendered":"<p>\u6700\u8fd1\u540c\u4eba\u5728\u958b\u767c\u8cc7\u6599\u5256\u6790\u7684\u7a0b\u5f0f\u6642\uff0c\u78b0\u5230\u4e00\u500b\u5f88\u5947\u602a\u7684\u73fe\u8c61\u3002\u6211\u4f7f\u7528 <a href=\"http:\/\/www.cplusplus.com\/reference\/stl\/map\/\" target=\"_blank\"><code>map<\/code> \u5bb9\u5668<\/a>\u4f86\u5b58\u653e\u5256\u6790\u8cc7\u6599\u7684\u7d50\u679c\uff0c\u7136\u800c\u537b\u767c\u73fe\u4ee5\u539f\u5148\u65b0\u589e\u8cc7\u6599\u6240\u7528\u7684\u76f8\u540c\u9375\u503c\uff0c\u7adf\u7136\u6703\u627e\u4e0d\u5230\u8a72\u7b46\u8cc7\u6599\u3002\u4f46\u6211\u7684\u6e2c\u8a66\u7a0b\u5f0f\u986f\u793a\u5bb9\u5668\u4e2d\u6240\u5b58\u653e\u7684\u9375\u503c\u8207\u8cc7\u6599\uff0c\u5176\u5167\u5bb9\u662f\u6b63\u78ba\u7684\uff0c\u4f46\u70ba\u4ec0\u9ebc\u7528\u76f8\u540c\u9375\u503c\u53bb\u627e\uff0c\u7d50\u679c\u7adf\u7136\u56de\u50b3\u67e5\u7121\u8cc7\u6599\u5462\uff1f\u539f\u4f86\u554f\u984c\u5c31\u51fa\u5728\u4ee5\u5b57\u5143\u4e32\u5217\u5e38\u6578\u7576\u7d22\u5f15\u9375\u503c\u3002<!--more--><\/p>\n<p>\u7531\u65bc\u6211\u6240\u958b\u767c\u7684\u9019\u500b\u7a0b\u5f0f\uff0c\u5b83\u63a5\u53d7\u8a31\u591a\u4e0d\u540c\u683c\u5f0f\u7684\u8cc7\u6599\uff0c\u5404\u7a2e\u683c\u5f0f\u6240\u4f7f\u7528\u7684\u6b04\u4f4d\u540d\u7a31\u4e5f\u90fd\u4e0d\u540c\u3002\u70ba\u4e86\u8a2d\u8a08\u7684\u7c21\u55ae\u5316\uff0c\u540c\u4eba\u628a\u62c6\u89e3\u683c\u5f0f\u8207\u5c0d\u6620\u7684\u5de5\u4f5c\u5206\u958b\u4f86\u8655\u7406\uff0c\u4e26\u4e14\u628a\u62c6\u89e3\u8207\u5c0d\u6620\u7684\u8cc7\u6599\u90fd\u5b58\u653e\u5728 <code>map<\/code> \u5bb9\u5668\u4e2d\uff0c\u800c\u4e0d\u53bb\u8a2d\u8a08\u5b58\u653e\u8cc7\u6599\u7269\u4ef6\u7684\u985e\u5225\uff0c\u4ee5\u514d\u65e5\u5f8c\u53d7\u5230\u6b04\u4f4d\u898f\u683c\u8b8a\u52d5\u7684\u5f71\u97ff\u800c\u5927\u52d5\u7a0b\u5f0f\u78bc\u3002<\/p>\n<p>\u8003\u616e\u8cc7\u6599\u8655\u7406\u7684\u6548\u7387\u8207\u6613\u8b80\u6027\uff0c\u540c\u4eba\u5c07\u5bb9\u5668\u7684\u9375\u503c\u8a2d\u70ba\u5b57\u5143\u4e32\u5217\u5e38\u6578\uff08<code>const char*<\/code>\uff09\u3002\u7a0b\u5f0f\u5256\u6790\u8cc7\u6599\u7684\u7d50\u679c\uff0c\u4ee5\u6e2c\u8a66\u7a0b\u5f0f\u78ba\u8a8d\u5bb9\u5668\u5167\u5bb9\u7121\u8aa4\uff0c\u4f46\u7b49\u5230\u5be6\u969b\u547c\u53eb\u6b64\u7a0b\u5f0f\u537b\u767c\u73fe\uff0c\u7121\u6cd5\u4ee5\u5bb9\u5668\u5167\u542b\u76f8\u540c\u9375\u503c\u4f86\u53d6\u5f97\u6240\u9700\u8981\u7684\u8cc7\u6599\u3002<\/p>\n<p>\u600e\u9ebc\u6703\u9019\u6a23\u5462\uff1f\u7528\u8d70\u8a2a map \u5bb9\u5668\u7684\u65b9\u5f0f\u50be\u5370\u5bb9\u5668\u5167\u542b\u8cc7\u6599\u6c92\u554f\u984c\uff0c\u4f46\u76f4\u63a5\u7528 <code>find ()<\/code> \u53d6\u5f97\u8cc7\u6599\u537b\u5f97\u5230\u7684\u662f <code>map::end ()<\/code>\u3002\u540c\u4eba\u4e0d\u4fe1\u90aa\uff0c\u7528\u8d70\u8a2a\u6240\u4f7f\u7528\u7684<a href=\"http:\/\/www.sgi.com\/tech\/stl\/Iterators.html\" target=\"_blank\">\u8fed\u4ee3\u5668<\/a>\u6240\u6307\u5411\u7684\u9375\u503c\u4f86 <code>find ()<\/code>\uff0c\u7d50\u679c\u53ef\u4ee5\u6b63\u78ba\u7121\u8aa4\u627e\u5230\u8cc7\u6599\u3002\u9019\u986f\u793a\u8457\u76f4\u63a5 <code>find ()<\/code> \u548c\u7528\u8fed\u4ee3\u5668\u6307\u5411\u7684\u9375\u503c\u5169\u8005\u4e26\u4e0d\u4e00\u6a23\uff0c\u4f46\u540c\u6a23\u662f <code>const char*<\/code>\uff0c\u5167\u5bb9\u503c\u53c8\u4e00\u6a21\u4e00\u6a23\uff0c\u5169\u8005\u61c9\u8a72\u662f\u76f8\u540c\u7684\u624d\u5c0d\u5440\uff01<\/p>\n<p>\u800c\u4e14\uff0c\u5982\u679c\u662f\u7528 <code>const char*<\/code> \u7576\u7d22\u5f15\u9375\u503c\u6709\u554f\u984c\uff0c\u90a3\u9ebc\u70ba\u4ec0\u9ebc\u4ee5\u540c\u6a23\u7684\u5bb9\u5668\u64cd\u4f5c\u6a21\u5f0f\uff0c\u5728\u62c6\u89e3\u683c\u5f0f\u7684\u8655\u7406\u6c92\u6709\u554f\u984c\uff0c\u800c\u537b\u6703\u5728\u6b04\u4f4d\u5c0d\u6620\u6642\u51fa\u73fe\u932f\u8aa4\u5462\uff1f\u6bd4\u8f03\u5169\u8005\u7684\u5dee\u7570\uff0c\u6211\u60f3\u6211\u77e5\u9053\u554f\u984c\u51fa\u5728\u4ec0\u9ebc\u5730\u65b9\u4e86\u3002\u6211\u8a66\u8457\u4ee5\u6574\u6578\u4f86\u53d6\u4ee3\u5b57\u5143\u4e32\u5217\u5e38\u6578\u4f86\u7576\u7d22\u5f15\u9375\u503c\uff0c\u53cd\u6b63\u96d6\u7136\u5404\u7a2e\u683c\u5f0f\u6b04\u4f4d\u4e92\u7570\uff0c\u4f46\u6700\u5f8c\u5c0d\u61c9\u5230\u7684\u6b04\u4f4d\u90fd\u662f\u76f8\u540c\u7684\u3002\u679c\u7136\uff0c\u627e\u4e0d\u5230\u8cc7\u6599\u7684\u554f\u984c\u5c31\u4e0d\u518d\u51fa\u73fe\u4e86\u3002<\/p>\n<p>\u5176\u5be6\u5b57\u5143\u4e32\u5217\u9375\u503c\u7684\u6bd4\u8f03\u662f\u57fa\u65bc\u8cc7\u6599\u5b58\u653e\u4f4d\u5740\u800c\u975e\u8cc7\u6599\u5167\u542b\u503c\uff0c\u53ea\u662f\u5e38\u6578\u8b8a\u6578\u7de8\u8b6f\u5668\u6703\u5e6b\u6211\u5011\u628a\u76f8\u540c\u5167\u5bb9\u7684\u5b57\u5143\u4e32\u5217\u653e\u5728\u4e00\u8d77\u3002\u4f46\u7531\u65bc\u540c\u4eba\u4e26\u4e0d\u662f\u7528\u5ba3\u544a <code>const<\/code> \u5e38\u6578\u800c\u662f\u7528 <code>#define<\/code> \u7684\u65b9\u5f0f\u4f86\u5b9a\u7fa9\u5e38\u6578\uff0c\u5c0d\u65bc\u4e0d\u540c\u7a0b\u5f0f\u78bc\u7684\u76f8\u540c\u5b57\u5143\u4e32\u5217\u5e38\u6578\uff0c\u53ef\u80fd\u7de8\u8b6f\u5668\u4e26\u4e0d\u6703\u5c07\u4ed6\u5011\u8996\u6703\u76f8\u540c\u7684\u8b8a\u6578\uff0c\u7d50\u679c\u5c31\u6703\u9020\u6210\u6bd4\u5c0d\u4e0d\u540c\u800c\u7121\u6cd5\u627e\u5230\u8cc7\u6599\u4e86\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u7528\u6574\u6578\u4f86\u53d6\u4ee3\u5b57\u5143\u4e32\u5217\u5e38\u6578\u7576\u7d22\u5f15\u9375\u503c\u5c31\u53ef\u4ee5\u907f\u514d\u4ee5\u4e0a\u7684\u554f\u984c\uff0c\u800c\u4e14\u4e5f\u7701\u4e0b\u7528\u4f86\u5b58\u653e\u5b57\u5143\u4e32\u5217\u5e38\u6578\u7684\u7a7a\u9593\uff0c\u4f46\u537b\u6709\u6578\u503c\u4ee3\u78bc\u4ee3\u8868\u610f\u7fa9\u4e0d\u660e\u800c\u9020\u6210\u7dad\u8b77\u7684\u554f\u984c\u3002\u91dd\u5c0d\u9019\u500b\u554f\u984c\u6211\u5011\u53ef\u4ee5\u5ba3\u544a <code>enum<\/code> \u8b8a\u6578\u4f86\u89e3\u6c7a\uff0c\u4f46\u5176\u7d22\u5f15\u9375\u503c\u9084\u662f\u61c9\u8a72\u7528 <code>unsigned int<\/code> \u800c\u4e0d\u80fd\u4f7f\u7528 <code>enum<\/code> \u578b\u614b\u3002\u70ba\u4ec0\u9ebc\u5462\uff1f\u56e0\u70ba <code>enum<\/code> \u662f <a href=\"http:\/\/www.sgi.com\/tech\/stl\/EqualityComparable.html\" target=\"_blank\">equality comparable<\/a> \u800c\u4e0d\u662f <a href=\"http:\/\/www.sgi.com\/tech\/stl\/LessThanComparable.html\" target=\"_blank\">less than comparable<\/a>\uff0c\u800c <code>map<\/code> \u662f <a href=\"http:\/\/www.sgi.com\/tech\/stl\/AssociativeContainer.html\" target=\"_blank\">associative container<\/a>\uff0c\u5176\u9375\u503c\u5fc5\u9808\u662f less than comparable \u5440\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u540c\u4eba\u5728\u958b\u767c\u8cc7\u6599\u5256\u6790\u7684\u7a0b\u5f0f\u6642\uff0c\u78b0\u5230\u4e00\u500b\u5f88\u5947\u602a\u7684\u73fe\u8c61\u3002\u6211\u4f7f\u7528 map \u5bb9\u5668\u4f86\u5b58\u653e &hellip; <a href=\"https:\/\/lifeparty.idv.tw\/blog\/archives\/1950\">\u95b1\u8b80\u5168\u6587 <span class=\"meta-nav\">&rarr;<\/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":[24,37,43],"tags":[],"class_list":["post-1950","post","type-post","status-publish","format-standard","hentry","category-24","category-37","category-43"],"_links":{"self":[{"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/posts\/1950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/comments?post=1950"}],"version-history":[{"count":25,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/posts\/1950\/revisions"}],"predecessor-version":[{"id":1975,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/posts\/1950\/revisions\/1975"}],"wp:attachment":[{"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/media?parent=1950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/categories?post=1950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lifeparty.idv.tw\/blog\/wp-json\/wp\/v2\/tags?post=1950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}