{"id":30689,"date":"2024-11-25T15:33:33","date_gmt":"2024-11-25T07:33:33","guid":{"rendered":"https:\/\/fwq.ai\/blog\/30689\/"},"modified":"2024-11-25T15:33:33","modified_gmt":"2024-11-25T07:33:33","slug":"%e6%8e%a8%e8%8d%9010%e4%b8%aa%e5%85%b3%e4%ba%8eicollection%e7%9a%84%e5%ae%9e%e4%be%8b%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/30689\/","title":{"rendered":"\u63a8\u835010\u4e2a\u5173\u4e8eICollection\u7684\u5b9e\u4f8b\u6559\u7a0b"},"content":{"rendered":"<p>\u7c7b\u56fe\/** &nbsp;*&nbsp;\u81ea\u5b9a\u4e49\u96c6\u5408\u63a5\u53e3,&nbsp;\u7c7b\u4f3cjava.util.Collection &nbsp;*&nbsp;\u7528\u4e8e\u6570\u636e\u5b58\u50a8 &nbsp;*&nbsp;@author&nbsp;stone &nbsp;* &nbsp;*\/ public&nbsp;interface&nbsp;ICollection &nbsp;{ IIterator &nbsp;iterator();&nbsp;\/\/\u8fd4\u56de\u8fed\u4ee3\u5668 void&nbsp;add(T&nbsp;t); T&nbsp;get(int&nbsp;index); }\/** &nbsp;*&nbsp;\u81ea\u5b9a\u4e49\u8fed\u4ee3\u5668\u63a5\u53e3&nbsp;\u7c7b\u4f3c\u4e8ejava.util.Iterator &nbsp;*&nbsp;\u7528\u4e8e\u904d\u5386\u96c6\u5408\u7c7bICollection\u7684\u6570\u636e &nbsp;*&amp;nb <\/p>\n<p><span style=\"line-height: 1.76em\">1. <\/span><\/p>\n<p><span style=\"line-height: 1.76em\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/194\/24b04e457f0281d816eec116b2366887.png\" style=\"max-width:90%\" class=\"aligncenter\" title=\"\u63a8\u835010\u4e2a\u5173\u4e8eICollection\u7684\u5b9e\u4f8b\u6559\u7a0b\u63d2\u56fe\" alt=\"\u63a8\u835010\u4e2a\u5173\u4e8eICollection\u7684\u5b9e\u4f8b\u6559\u7a0b\u63d2\u56fe\" \/><\/span><\/p>\n<p><span style=\"line-height: 1.76em\">\u7b80\u4ecb\uff1a\u7c7b\u56fe\/** * \u81ea\u5b9a\u4e49\u96c6\u5408\u63a5\u53e3, \u7c7b\u4f3cjava.util.Collection * \u7528\u4e8e\u6570\u636e\u5b58\u50a8 * @author stone * *\/public interface ICollection { IIterator iterator(); \/\/\u8fd4\u56de\u8fed\u4ee3\u5668 void add(T t); T get(int index);}\/** * \u81ea\u5b9a\u4e49\u8fed\u4ee3\u5668\u63a5\u53e3 \u7c7b<\/span><\/p>\n<p><span style=\"line-height: 1.76em\">2. <\/span><\/p>\n<p><span style=\"line-height: 1.76em\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/194\/5ff9fb70aae2ff306ad9954ae917314b.png\" style=\"max-width:90%\" class=\"aligncenter\" title=\"\u63a8\u835010\u4e2a\u5173\u4e8eICollection\u7684\u5b9e\u4f8b\u6559\u7a0b\u63d2\u56fe1\" alt=\"\u63a8\u835010\u4e2a\u5173\u4e8eICollection\u7684\u5b9e\u4f8b\u6559\u7a0b\u63d2\u56fe1\" \/><\/span><\/p>\n<p><span style=\"line-height: 1.76em\">\u7b80\u4ecb\uff1a\u3000\u3000\u96c6\u5408\u662f.NET FCL(Framework Class Library)\u4e2d\u5f88\u91cd\u8981\u7684\u4e00\u90e8\u5206\uff0c\u4e5f\u662f\u6211\u4eec\u5f00\u53d1\u5f53\u4e2d\u6700\u5e38\u7528\u5230\u7684\u529f\u80fd\u4e4b\u4e00\uff0c\u51e0\u4e4e\u662f\u65e0\u5904\u4e0d\u5728\u3002\u4fd7\u8bdd\u8bf4\u77e5\u5176\u7136\uff0c\u77e5\u5176\u6240\u4ee5\u7136\uff0c\u5e73\u5e38\u770b\u5230IEnumerable\uff0cIEnumerator\uff0cICollection\u662f\u4e0d\u662f\u77e5\u9053\u4ed6\u4eec\u4e4b\u95f4\u5404\u81ea\u7684\u533a\u522b\uff1f\u9664\u4e86List\u548cDictionary\u4ee5\u5916\uff0c\u4f60\u8fd8\u7528\u8fc7\u54ea\u4e9b\u5176\u5b83\u7684\u96c6\u5408\u7c7b\uff1f\u5e9f\u8bdd\u5c11\u8bf4\uff0c\u4eca\u5929\u6211\u4eec\u5c31\u6765\u770b\u4e00\u4e9b\u8fd9\u4e9b\u5b9a\u4e49\u96c6\u5408\u7c7b\u7684\u63a5\u53e3\u4ee5\u53ca\u4ed6\u4eec\u7684\u5b9e\u73b0\u3002<\/span><\/p>\n<p><span style=\"line-height: 1.76em\">3. <\/span><\/p>\n<p><span style=\"line-height: 1.76em\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/194\/7b28ddfcdb41bb39e24b7722d95a0ca8.png\" style=\"max-width:90%\" class=\"aligncenter\" title=\"\u63a8\u835010\u4e2a\u5173\u4e8eICollection\u7684\u5b9e\u4f8b\u6559\u7a0b\u63d2\u56fe2\" alt=\"\u63a8\u835010\u4e2a\u5173\u4e8eICollection\u7684\u5b9e\u4f8b\u6559\u7a0b\u63d2\u56fe2\" \/><\/span><\/p>\n<p><span style=\"line-height: 1.76em\">\u7b80\u4ecb\uff1a\u4e86\u89e3\u4e86ICollection\u63a5\u53e3\u3001\u8fed\u4ee3\u4ee5\u53ca\u6cdb\u578b\u96c6\u5408\uff0c\u4e0b\u9762\u518d\u8be6\u7ec6\u4e86\u89e3\u4e00\u4e0bIList\u63a5\u53e3\u3002<\/span><\/p>\n<p><span style=\"line-height: 1.76em\">4. <\/span><\/p>\n<p><span style=\"line-height: 1.76em\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/194\/ec728c69abeb6a1d9e1a1d260310973f.png\" style=\"max-width:90%\" class=\"aligncenter\" title=\"\u63a8\u835010\u4e2a\u5173\u4e8eICollection\u7684\u5b9e\u4f8b\u6559\u7a0b\u63d2\u56fe3\" alt=\"\u63a8\u835010\u4e2a\u5173\u4e8eICollection\u7684\u5b9e\u4f8b\u6559\u7a0b\u63d2\u56fe3\" \/><\/span><\/p>\n<p><span style=\"line-height: 1.76em\">\u7b80\u4ecb\uff1a\u6570\u7ec4\u662f.net framework\u5b9a\u4e49\u7684\u6700\u57fa\u672c\u7684\u96c6\u5408\u7c7b\u578b\uff0c\u9664\u4e86\u6570\u7ec4\uff0c.net framework\u8fd8\u5b9a\u4e49\u4e86\u5f88\u591a\u96c6\u5408\u7c7b\u578b\u3002\u6253\u5f00msdn\u53ef\u4ee5\u770b\u5230\uff0c\u6240\u6709\u96c6\u5408\u90fd\u5728System.Collections\u547d\u540d\u7a7a\u95f4\u4e0b\uff1a<\/span><\/p>\n<p><span style=\"line-height: 1.76em\">5. <\/span><\/p>\n<p><span style=\"line-height: 1.76em\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/013\/ddcbffb9f1cc1cf035ef593e9d342c7c.png\" style=\"max-width:90%\" class=\"aligncenter\" title=\"\u63a8\u835010\u4e2a\u5173\u4e8eICollection\u7684\u5b9e\u4f8b\u6559\u7a0b\u63d2\u56fe4\" alt=\"\u63a8\u835010\u4e2a\u5173\u4e8eICollection\u7684\u5b9e\u4f8b\u6559\u7a0b\u63d2\u56fe4\" \/><\/span><\/p>\n<p><span style=\"line-height: 1.76em\">\u7b80\u4ecb\uff1aarraylist\u662f\u52a8\u6001\u6570\u7ec4\uff0c\u5b83\u5177\u6709\u4e09\u4e2a\u597d\u5904\u5206\u522b\u662f:\u52a8\u6001\u7684\u589e\u52a0\u548c\u51cf\u5c11\u5143\u7d20 \u3001\u5b9e\u73b0\u4e86ICollection\u548cIList\u63a5\u53e3\u3001\u7075\u6d3b\u7684\u8bbe\u7f6e\u6570\u7ec4\u7684\u5927\u5c0f\uff0c\u672c\u6587\u7ed9\u5927\u5bb6\u4ecb\u7ecdjava arraylist\u904d\u5386\u53caJava arraylist \u7528\u6cd5\uff0c\u611f\u5174\u8da3\u7684\u670b\u53cb\u4e00\u8d77\u5b66\u4e60\u5427<\/span><\/p>\n<p><strong>\u3010\u76f8\u5173\u95ee\u7b54\u63a8\u8350\u3011\uff1a<\/strong><\/p>\n<\/p>\n<\/p>\n<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u63a8\u835010\u4e2a\u5173\u4e8eICollection\u7684\u5b9e\u4f8b\u6559\u7a0b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7c7b\u56fe\/** &nbsp;*&nbsp;\u81ea\u5b9a\u4e49\u96c6\u5408\u63a5\u53e3,&nbsp;\u7c7b\u4f3cjava.util.Collection &nbsp;*&nbsp;\u7528\u4e8e\u6570\u636e\u5b58\u50a8 &nbsp;*&nbsp;@author&nbsp;stone &nbsp;* &nbsp;*\/ public&nbsp;interface&nbsp;ICollection &nbsp;{ IIterator &nbsp;iterator();&nbsp;\/\/\u8fd4\u56de\u8fed\u4ee3\u5668 void&nbsp;add(T&nbsp;t); T&nbsp;get(int&nbsp;index); }\/** &nbsp;*&nbsp;\u81ea\u5b9a\u4e49\u8fed\u4ee3\u5668\u63a5\u53e3&nbsp;\u7c7b\u4f3c\u4e8ejava.util.Iterator &nbsp;*&nbsp;\u7528\u4e8e\u904d\u5386\u96c6\u5408\u7c7bICollection\u7684\u6570\u636e &nbsp;*&amp;nb 1. \u7b80\u4ecb\uff1a\u7c7b\u56fe\/** * \u81ea\u5b9a\u4e49\u96c6\u5408\u63a5\u53e3, \u7c7b\u4f3cjava.util.Collection * \u7528\u4e8e\u6570\u636e\u5b58\u50a8 * @author stone * *\/public interface ICollection { IIterator iterator(); \/\/\u8fd4\u56de\u8fed\u4ee3\u5668 void add(T t); T get(int index);}\/** * \u81ea\u5b9a\u4e49\u8fed\u4ee3\u5668\u63a5\u53e3 \u7c7b 2. \u7b80\u4ecb\uff1a\u3000\u3000\u96c6\u5408\u662f.NET FCL(Framework Class Library)\u4e2d\u5f88\u91cd\u8981\u7684\u4e00\u90e8\u5206\uff0c\u4e5f\u662f\u6211\u4eec\u5f00\u53d1\u5f53\u4e2d\u6700\u5e38\u7528\u5230\u7684\u529f\u80fd\u4e4b\u4e00\uff0c\u51e0\u4e4e\u662f\u65e0\u5904\u4e0d\u5728\u3002\u4fd7\u8bdd\u8bf4\u77e5\u5176\u7136\uff0c\u77e5\u5176\u6240\u4ee5\u7136\uff0c\u5e73\u5e38\u770b\u5230IEnumerable\uff0cIEnumerator\uff0cICollection\u662f\u4e0d\u662f\u77e5\u9053\u4ed6\u4eec\u4e4b\u95f4\u5404\u81ea\u7684\u533a\u522b\uff1f\u9664\u4e86List\u548cDictionary\u4ee5\u5916\uff0c\u4f60\u8fd8\u7528\u8fc7\u54ea\u4e9b\u5176\u5b83\u7684\u96c6\u5408\u7c7b\uff1f\u5e9f\u8bdd\u5c11\u8bf4\uff0c\u4eca\u5929\u6211\u4eec\u5c31\u6765\u770b\u4e00\u4e9b\u8fd9\u4e9b\u5b9a\u4e49\u96c6\u5408\u7c7b\u7684\u63a5\u53e3\u4ee5\u53ca\u4ed6\u4eec\u7684\u5b9e\u73b0\u3002 3. \u7b80\u4ecb\uff1a\u4e86\u89e3\u4e86ICollection\u63a5\u53e3\u3001\u8fed\u4ee3\u4ee5\u53ca\u6cdb\u578b\u96c6\u5408\uff0c\u4e0b\u9762\u518d\u8be6\u7ec6\u4e86\u89e3\u4e00\u4e0bIList\u63a5\u53e3\u3002 4. \u7b80\u4ecb\uff1a\u6570\u7ec4\u662f.net framework\u5b9a\u4e49\u7684\u6700\u57fa\u672c\u7684\u96c6\u5408\u7c7b\u578b\uff0c\u9664\u4e86\u6570\u7ec4\uff0c.net framework\u8fd8\u5b9a\u4e49\u4e86\u5f88\u591a\u96c6\u5408\u7c7b\u578b\u3002\u6253\u5f00msdn\u53ef\u4ee5\u770b\u5230\uff0c\u6240\u6709\u96c6\u5408\u90fd\u5728System.Collections\u547d\u540d\u7a7a\u95f4\u4e0b\uff1a 5. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-30689","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30689","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=30689"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30689\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=30689"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=30689"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=30689"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}