{"id":109078,"date":"2026-09-23T09:40:44","date_gmt":"2026-09-23T01:40:44","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/109078.html"},"modified":"2026-09-23T09:40:44","modified_gmt":"2026-09-23T01:40:44","slug":"%e3%80%90%e4%bb%93%e9%a2%89%e8%af%ad%e8%a8%80%e5%85%a5%e9%97%a8-%c2%b7-%e7%ac%ac14%e8%af%be%e3%80%91","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/109078.html","title":{"rendered":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c14\u8bfe\u3011"},"content":{"rendered":"<h2>\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c14\u8bfe\u3011\u8fed\u4ee3\u5668 Iterator \u4e0e\u60f0\u6027\u5e8f\u5217<\/h2>\n<p>\u7b2c 13 \u8bfe\u7528\u95ed\u5305\u505a\u51fa\u4e86&#034;\u80fd\u8bb0\u4f4f\u72b6\u6001\u7684\u51fd\u6570&#034;&#xff0c;\u8fd9\u8282\u8bfe\u89e3\u51b3\u4e00\u4e2a\u66f4\u5b9e\u9645\u7684\u95ee\u9898&#xff1a;\u60f3\u9010\u4e2a\u4ea7\u51fa\u4e00\u7cfb\u5217\u503c\u2014\u2014\u5927\u6587\u4ef6\u7684\u9010\u884c\u8bfb\u53d6\u3001\u4f20\u611f\u5668\u6e90\u6e90\u4e0d\u65ad\u7684\u8bfb\u6570\u3001\u751a\u81f3\u6590\u6ce2\u90a3\u5951\u90a3\u6837\u65e0\u7a77\u65e0\u5c3d\u7684\u6570\u5217\u2014\u2014\u96be\u9053\u90fd\u8981\u5148\u4e00\u53e3\u6c14\u7b97\u5b8c\u585e\u8fdb\u6570\u7ec4&#xff1f;\u5f53\u7136\u4e0d\u662f\u3002\u4ed3\u9889\u7684\u7b54\u6848\u662f\u8fed\u4ee3\u5668&#xff08;Iterator&#xff09;&#xff1a;\u7528\u4e00\u4e2a next() \u65b9\u6cd5\u6309\u9700\u53d6\u503c&#xff0c;\u7528\u591a\u5c11\u7b97\u591a\u5c11\u3002<\/p>\n<p>\u672c\u6587\u6240\u6709\u4ee3\u7801\u4e0e\u62a5\u9519\u6587\u6848\u5747\u5728\u4ed3\u9889 SDK 1.1.3 \u4e0b\u9010\u884c\u5b9e\u6d4b\u7f16\u8bd1\u8fd0\u884c\u3002\u9014\u4e2d\u4f1a\u6f84\u6e05\u56db\u4e2a\u9ad8\u9891\u8bef\u533a&#xff08;\u6bcf\u4e00\u4e2a\u90fd\u662f\u7f16\u8bd1\u5668\u4eb2\u81ea\u544a\u8bc9\u6211\u7684&#xff09;&#xff1a;\u2460 \u4ed3\u9889 1.1.3 \u6ca1\u6709 Python\/JS \u90a3\u79cd yield \/ sequence { } \u751f\u6210\u5668\u8bed\u6cd5\u7cd6&#xff0c;\u60f0\u6027\u5e8f\u5217\u9760\u624b\u5199\u8fed\u4ee3\u5668\u7c7b&#xff1b;\u2461 \u6570\u7ec4\u4e0a\u76f4\u63a5\u8c03 map \/ filter \u662f\u7acb\u5373\u6c42\u503c\u8fd4\u56de\u65b0\u6570\u7ec4&#xff0c;\u5148 iterator() \u518d\u8c03\u624d\u662f\u60f0\u6027\u94fe&#xff1b;\u2462 Iterator \u548c Iterable \u662f\u4e24\u4e2a\u5e76\u5217\u63a5\u53e3&#xff0c;\u4e0d\u662f\u7ee7\u627f\u5173\u7cfb&#xff1b;\u2463 \u8fed\u4ee3\u5668\u4e0a\u6ca1\u6709 toArray()\u3001drop()\u3001chain()\u3001sum()&#xff0c;\u6b63\u786e\u7684\u540d\u5b57\u5206\u522b\u662f&#034;\u624b\u52a8\u6536\u96c6&#034;\u3001skip()\u3001concat()\u3001fold()\u3002<\/p>\n<hr \/>\n<h3>\u76ee\u5f55&#xff08;\u7cfb\u5217\u5bfc\u822a&#xff09;<\/h3>\n<p>\u6574\u5957\u8def\u7ebf\u5171 7 \u4e2a\u6a21\u5757\u300130 \u8bfe&#xff1a;<\/p>\n<p>| \u6a21\u5757 | \u8bfe\u6b21 | \u5185\u5bb9 | | \u2014 | \u2014 | \u2014 \u2014 | | \u4e00\u3001\u73af\u5883\u4e0e\u5165\u95e8 | 01&#xff5e;05 | \u73af\u5883\u642d\u5efa\u4e0e Hello World\u3001\u53d8\u91cf\u4e0e\u57fa\u672c\u7c7b\u578b\u3001\u8fd0\u7b97\u7b26\u4e0e\u8f93\u5165\u8f93\u51fa\u3001\u5206\u652f\u3001\u5faa\u73af | | \u4e8c\u3001\u5e38\u7528\u7c7b\u578b\u4e0e\u6570\u636e\u7ec4\u7ec7 | 06&#xff5e;10 | \u5b57\u7b26\u4e32\u3001\u6570\u7ec4\u4e0e\u533a\u95f4\u3001ArrayList\/HashMap\/HashSet\u3001\u53ef\u7a7a\u7c7b\u578b\u3001\u9519\u8bef\u5904\u7406 | | \u4e09\u3001\u51fd\u6570\u4e0e\u51fd\u6570\u5f0f | 11&#xff5e;14 | \u51fd\u6570\u3001Lambda \u4e0e\u9ad8\u9636\u51fd\u6570\u3001\u95ed\u5305\u3001\u8fed\u4ee3\u5668\u4e0e\u60f0\u6027\u5e8f\u5217 | | \u56db\u3001\u9762\u5411\u5bf9\u8c61\u4e0e\u7c7b\u578b\u7cfb\u7edf | 15&#xff5e;20 | struct\/class\u3001\u6784\u9020\u4e0e\u5c5e\u6027\u3001\u63a5\u53e3\u3001\u679a\u4e3e\u4e0e match \u6a21\u5f0f\u5339\u914d\u3001\u6cdb\u578b\u3001\u6269\u5c55 | | \u4e94\u3001\u5de5\u7a0b\u5316\u4e0e\u6807\u51c6\u5e93 | 21&#xff5e;25 | cjpm \u5305\u7ba1\u7406\u4e0e\u591a\u6587\u4ef6\u3001\u6587\u4ef6 IO\u3001JSON \u5904\u7406\u3001\u7f51\u7edc\u7f16\u7a0b\u3001\u5355\u5143\u6d4b\u8bd5 | | \u516d\u3001\u5e76\u53d1\u7f16\u7a0b | 26&#xff5e;28 | \u7ebf\u7a0b\u3001Channel \u901a\u9053\u4e0e\u540c\u6b65\u539f\u8bed\u3001\u5e76\u53d1\u5b9e\u6218 | | \u4e03\u3001\u9879\u76ee\u5b9e\u6218 | 29&#xff5e;30 | \u547d\u4ee4\u884c\u5c0f\u5de5\u5177\u3001GeoJSON \u6570\u636e\u5904\u7406\u5b9e\u6218 |<\/p>\n<li>\u73af\u5883\u642d\u5efa\u4e0e\u7b2c\u4e00\u4e2a\u4ed3\u9889\u7a0b\u5e8f<\/li>\n<li>\u53d8\u91cf\u4e0e\u5e38\u91cf&#xff1a;let \/ var \u4e0e\u57fa\u672c\u6570\u636e\u7c7b\u578b<\/li>\n<li>\u8fd0\u7b97\u7b26\u4e0e\u6807\u51c6\u8f93\u5165\u8f93\u51fa<\/li>\n<li>\u5206\u652f\u7ed3\u6784&#xff1a;if \u4e0e match \u8868\u8fbe\u5f0f<\/li>\n<li>\u5faa\u73af\u7ed3\u6784&#xff1a;while \/ for \/ Range<\/li>\n<li>\u5b57\u7b26\u4e32\u8be6\u89e3\u4e0e\u5b57\u7b26\u4e32\u63d2\u503c<\/li>\n<li>\u6570\u7ec4 Array \u4e0e\u533a\u95f4 Range<\/li>\n<li>\u96c6\u5408\u6846\u67b6&#xff1a;ArrayList\u3001HashMap\u3001HashSet<\/li>\n<li>\u53ef\u7a7a\u7c7b\u578b ? \u4e0e Option<\/li>\n<li>\u9519\u8bef\u5904\u7406&#xff1a;\u5f02\u5e38\u673a\u5236\u4e0e Result<\/li>\n<li>\u51fd\u6570\u5b9a\u4e49\u3001\u53c2\u6570\u4e0e\u8fd4\u56de\u503c<\/li>\n<li>Lambda \u4e0e\u9ad8\u9636\u51fd\u6570<\/li>\n<li>\u95ed\u5305\u3001\u4f5c\u7528\u57df\u4e0e\u51fd\u6570\u7c7b\u578b<\/li>\n<li>\u8fed\u4ee3\u5668 Iterator \u4e0e Sequence&#xff08;\u672c\u6587&#xff09;<\/li>\n<li>\u7ed3\u6784\u4f53 struct \u4e0e\u7c7b class<\/li>\n<li>\u6784\u9020\u51fd\u6570\u3001\u5c5e\u6027\u4e0e\u65b9\u6cd5<\/li>\n<li>\u63a5\u53e3 interface \u4e0e\u5b9e\u73b0<\/li>\n<li>\u679a\u4e3e enum\u3001\u4ee3\u6570\u6570\u636e\u7c7b\u578b\u4e0e match \u6a21\u5f0f\u5339\u914d<\/li>\n<li>\u6cdb\u578b\u7f16\u7a0b<\/li>\n<li>\u6269\u5c55\u3001\u7c7b\u578b\u522b\u540d\u4e0e\u53ef\u89c1\u6027\u63a7\u5236<\/li>\n<li>cjpm \u5305\u7ba1\u7406\u4e0e\u591a\u6587\u4ef6\u9879\u76ee\u7ec4\u7ec7<\/li>\n<li>\u6587\u4ef6\u4e0e\u76ee\u5f55 IO<\/li>\n<li>JSON \u5904\u7406&#xff08;\u7ed3\u5408 stdx \u6269\u5c55\u5e93&#xff09;<\/li>\n<li>\u7f51\u7edc\u7f16\u7a0b\u5165\u95e8<\/li>\n<li>\u5355\u5143\u6d4b\u8bd5<\/li>\n<li>\u5e76\u53d1\u57fa\u7840&#xff1a;\u7ebf\u7a0b\u7684\u521b\u5efa\u4e0e\u7b49\u5f85<\/li>\n<li>Channel \u901a\u9053\u4e0e\u540c\u6b65\u539f\u8bed<\/li>\n<li>\u5e76\u53d1\u5b9e\u6218&#xff1a;\u591a\u7ebf\u7a0b\u4efb\u52a1\u5904\u7406<\/li>\n<li>\u5b9e\u6218\u4e00&#xff1a;\u5e26\u6587\u4ef6\u6301\u4e45\u5316\u7684\u547d\u4ee4\u884c\u5c0f\u5de5\u5177<\/li>\n<li>\u5b9e\u6218\u4e8c&#xff1a;GeoJSON \u6570\u636e\u5904\u7406\u7a0b\u5e8f<\/li>\n<hr \/>\n<h3>\u4e00\u3001\u5148\u60f3\u6e05\u695a&#xff1a;\u4e3a\u4ec0\u4e48\u8981&#034;\u61d2&#034;<\/h3>\n<p>\u524d 8 \u8bfe\u5904\u7406\u6570\u636e&#xff0c;\u5957\u8def\u90fd\u662f&#034;\u5168\u90e8\u88c5\u8fdb\u5bb9\u5668&#xff0c;\u518d\u904d\u5386\u5904\u7406&#034;&#xff1a;<\/p>\n<p>let nums &#061; [1, 2, 3, 4, 5]<br \/>\nfor (n in nums) {<br \/>\n    println(n)<br \/>\n}<\/p>\n<p>\u8fd9\u5728\u6570\u636e\u91cf\u5c0f\u3001\u6570\u91cf\u6709\u9650\u65f6\u6beb\u65e0\u95ee\u9898\u3002\u4f46\u8bbe\u60f3\u4e09\u79cd\u573a\u666f&#xff1a;<\/p>\n<li>\u6570\u636e\u91cf\u5de8\u5927&#xff1a;\u4e00\u4e2a 10 GB \u7684\u65e5\u5fd7\u6587\u4ef6&#xff0c;\u4f60\u53ea\u60f3\u627e\u51fa\u524d 10 \u6761\u9519\u8bef\u3002\u4e00\u6b21\u6027\u8bfb\u8fdb\u5185\u5b58&#xff1f;\u673a\u5668\u76f4\u63a5\u5361\u6b7b\u3002<\/li>\n<li>\u6570\u636e\u65e0\u9650&#xff1a;\u6590\u6ce2\u90a3\u5951\u6570\u5217\u6ca1\u6709\u5c3d\u5934&#xff0c;\u81ea\u7136\u6570 1\u30012\u30013\u2026\u2026\u6c38\u8fdc\u6570\u4e0d\u5b8c&#xff0c;\u6839\u672c\u6ca1\u6cd5&#034;\u5148\u5168\u90e8\u88c5\u8fdb\u6570\u7ec4&#034;\u3002<\/li>\n<li>\u6570\u636e\u8fd8\u6ca1\u4ea7\u751f&#xff1a;\u4f20\u611f\u5668\u6bcf\u79d2\u4e0a\u62a5\u4e00\u6b21\u8bfb\u6570&#xff0c;\u5904\u7406\u7a0b\u5e8f\u5fc5\u987b&#034;\u6765\u4e00\u4e2a\u5904\u7406\u4e00\u4e2a&#034;\u3002<\/li>\n<p>\u8fd9\u4e09\u79cd\u573a\u666f\u7684\u5171\u540c\u70b9\u662f&#xff1a;\u503c\u4e0d\u5e94\u8be5\u63d0\u524d\u7b97\u597d&#xff0c;\u800c\u5e94\u8be5\u5728\u88ab\u9700\u8981\u7684\u90a3\u4e00\u523b\u624d\u7b97\u51fa\u6765\u3002\u8fd9\u5c31\u662f&#034;\u60f0\u6027\u6c42\u503c&#xff08;lazy evaluation&#xff09;\u201c\u3002\u8fed\u4ee3\u5668\u5c31\u662f\u627f\u8f7d\u60f0\u6027\u6c42\u503c\u7684\u5bf9\u8c61\u2014\u2014\u5b83\u50cf\u4e00\u4e2a&#034;\u6e38\u6807\u201d&#xff0c;\u4f60\u6bcf\u53eb\u4e00\u6b21 next()&#xff0c;\u5b83\u624d\u5f80\u524d\u8d70\u4e00\u6b65\u3001\u5410\u51fa\u4e00\u4e2a\u503c\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001Iterator \u63a5\u53e3&#xff1a;\u4e00\u4e2a next() \u65b9\u6cd5\u7684\u534f\u8bae<\/h3>\n<p>\u4ed3\u9889\u6807\u51c6\u5e93\u4e2d&#xff0c;\u8fed\u4ee3\u5668\u7684\u5b9a\u4e49\u6781\u5176\u7b80\u5355&#xff08;std.core \u5305&#xff0c;\u65e0\u9700 import&#xff09;&#xff1a;<\/p>\n<p>public interface Iterator&lt;T&gt; {<br \/>\n    func next(): Option&lt;T&gt;<br \/>\n}<\/p>\n<p>\u5c31\u4e00\u4e2a\u65b9\u6cd5&#xff1a;<\/p>\n<ul>\n<li>\u8fd4\u56de Some(\u503c)&#xff1a;\u6e38\u6807\u5f53\u524d\u4f4d\u7f6e\u6709\u503c&#xff0c;\u540c\u65f6\u6e38\u6807\u524d\u8fdb\u4e00\u6b65&#xff1b;<\/li>\n<li>\u8fd4\u56de None&#xff1a;\u5e8f\u5217\u5230\u5934\u4e86&#xff0c;\u4ee5\u540e\u518d\u8c03\u4e5f\u6c38\u8fdc\u662f None\u3002<\/li>\n<\/ul>\n<p>\u81ea\u5df1\u5199\u4e00\u4e2a\u8fed\u4ee3\u5668&#xff0c;\u53ea\u8981\u5b9e\u73b0\u8fd9\u4e2a\u63a5\u53e3\u3002\u6ce8\u610f\u4ed3\u9889\u7684\u8bed\u6cd5&#xff1a;\u63a5\u53e3\u5b9e\u73b0\u7528 &lt;:&#xff0c;\u63a5\u53e3\u65b9\u6cd5\u5728\u5b9e\u73b0\u7c7b\u91cc\u8981\u52a0 public&#xff1a;<\/p>\n<p>class Counter &lt;: Iterator&lt;Int64&gt; {<br \/>\n    var current: Int64 &#061; 1<br \/>\n    let limit: Int64<\/p>\n<p>    init(limit: Int64) {<br \/>\n        this.limit &#061; limit<br \/>\n    }<\/p>\n<p>    public func next(): Option&lt;Int64&gt; {<br \/>\n        if (current &lt;&#061; limit) {<br \/>\n            let v &#061; current<br \/>\n            current&#043;&#043;<br \/>\n            return Some(v)<br \/>\n        }<br \/>\n        return None<br \/>\n    }<br \/>\n}<\/p>\n<p>&#x1f6ab; \u4ed3\u9889\u7684\u7c7b\u6ca1\u6709\u4e3b\u6784\u9020\u51fd\u6570\u7b80\u5199\u3002\u5199 class Counter(var current: Int64, let limit: Int64)&#xff08;Kotlin \u98ce\u683c&#xff09;\u4f1a\u76f4\u63a5\u62a5 expected &#039;{&#039;, found &#039;(&#039;\u3002\u5fc5\u987b\u5148\u5728\u7c7b\u4f53\u91cc\u58f0\u660e\u5b57\u6bb5&#xff0c;\u518d\u5199 init \u6784\u9020\u51fd\u6570\u3002\u7b2c 15 \u8bfe\u4f1a\u4e13\u95e8\u8bb2&#xff0c;\u8fd9\u91cc\u5148\u7167\u6284\u683c\u5f0f\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u6d88\u8d39\u8fed\u4ee3\u5668\u7684\u4e09\u79cd\u59ff\u52bf<\/h3>\n<h4>3.1 \u624b\u52a8\u8c03 next()&#xff1a;while &#043; match<\/h4>\n<p>\u8fed\u4ee3\u5668\u6700\u539f\u59cb\u7684\u6d88\u8d39\u65b9\u5f0f\u3002\u4ed3\u9889 1.1.3 \u6ca1\u6709 while let Some(v) &#061; &#8230; \u8fd9\u7c7b\u8bed\u6cd5\u7cd6&#xff0c;\u6807\u51c6\u5199\u6cd5\u662f while (true) \u914d\u5408\u7b2c 4\u30019 \u8bfe\u7684 match&#xff1a;<\/p>\n<p>main(): Int64 {<br \/>\n    let c &#061; Counter(3)<br \/>\n    while (true) {<br \/>\n        match (c.next()) {<br \/>\n            case Some(v) &#061;&gt; print(&#034;${v} &#034;)<br \/>\n            case None &#061;&gt; break<br \/>\n        }<br \/>\n    }<br \/>\n    println()<br \/>\n    return 0<br \/>\n}<\/p>\n<p>\u8f93\u51fa&#xff1a;<\/p>\n<p>1 2 3<\/p>\n<p>None \u4e00\u51fa\u73b0\u5c31 break&#xff0c;\u6e38\u6807\u5230\u6b64\u8017\u5c3d\u3002<\/p>\n<h4>3.2 for-in&#xff1a;\u6700\u5e38\u7528<\/h4>\n<p>\u5b9e\u73b0\u4e86 Iterator \u7684\u5bf9\u8c61\u53ef\u4ee5\u76f4\u63a5\u653e\u8fdb for-in&#xff0c;\u7f16\u8bd1\u5668\u5e2e\u4f60\u91cd\u590d\u8c03 next() \u5e76\u5728 None \u65f6\u505c\u6b62&#xff1a;<\/p>\n<p>for (v in Counter(5)) {<br \/>\n    print(&#034;${v} &#034;)<br \/>\n}<\/p>\n<p>1 2 3 4 5<\/p>\n<h4>3.3 \u7ec8\u7aef\u65b9\u6cd5&#xff1a;\u51fd\u6570\u5f0f\u4e00\u628a\u68ad<\/h4>\n<p>\u8fed\u4ee3\u5668\u4e0a\u6302\u4e86\u5341\u51e0\u4e2a\u73b0\u6210\u65b9\u6cd5&#xff08;\u7b2c\u516d\u8282\u7ec6\u8bb2&#xff09;&#xff0c;forEach \u662f\u5176\u4e2d\u6700\u76f4\u63a5\u7684\u2014\u2014\u5bf9\u6bcf\u4e2a\u503c\u6267\u884c\u4e00\u4e2a Lambda&#xff1a;<\/p>\n<p>Counter(3).forEach { v &#061;&gt; print(&#034;${v} &#034;) }<\/p>\n<hr \/>\n<h3>\u56db\u3001Iterable \u63a5\u53e3&#xff1a;\u8ba9\u81ea\u5b9a\u4e49\u5bb9\u5668\u652f\u6301 for-in<\/h3>\n<p>Counter \u90a3\u79cd&#034;\u81ea\u5df1\u5c31\u662f\u6e38\u6807&#034;\u7684\u5bf9\u8c61\u9002\u5408\u4e00\u6b21\u6027\u904d\u5386\u3002\u4f46\u66f4\u591a\u65f6\u5019\u6211\u4eec\u6709\u7684\u662f\u5bb9\u5668&#xff08;\u4e66\u67b6\u3001\u6210\u7ee9\u8868\u3001\u4f20\u611f\u5668\u4e00\u5468\u7684\u6570\u636e&#xff09;\u2014\u2014\u5bb9\u5668\u5e0c\u671b\u80fd\u88ab\u53cd\u590d\u904d\u5386&#xff0c;\u6bcf\u6b21\u904d\u5386\u90fd\u4ece\u5934\u5f00\u59cb\u3002<\/p>\n<p>\u8fd9\u65f6\u7528\u53e6\u4e00\u4e2a\u63a5\u53e3 Iterable&lt;T&gt;&#xff0c;\u5b83\u540c\u6837\u53ea\u6709\u4e00\u4e2a\u65b9\u6cd5&#xff1a;<\/p>\n<p>public interface Iterable&lt;T&gt; {<br \/>\n    func iterator(): Iterator&lt;T&gt;<br \/>\n}<\/p>\n<p>\u6ce8\u610f\u5b83\u7684\u65b9\u6cd5\u7b7e\u540d&#xff1a;\u8fd4\u56de\u4e00\u4e2a\u8fed\u4ee3\u5668\u3002\u8fd9\u662f\u4e00\u4e2a&#034;\u5de5\u5382\u65b9\u6cd5&#034;\u2014\u2014\u6bcf\u8c03\u7528\u4e00\u6b21&#xff0c;\u5c31\u751f\u4ea7\u51fa\u4e00\u4e2a\u6e38\u6807\u5728\u8d77\u70b9\u7684\u5168\u65b0\u8fed\u4ee3\u5668\u3002<\/p>\n<p>\u5b8c\u6574\u5957\u8def\u662f&#034;\u5bb9\u5668 &#043; \u4e13\u5c5e\u6e38\u6807\u7c7b&#034;\u4e24\u4ef6\u5957&#xff1a;<\/p>\n<p>\/\/ \u6e38\u6807&#xff1a;\u6301\u6709\u5bb9\u5668\u5f15\u7528\u548c\u5f53\u524d\u4e0b\u6807<br \/>\nclass RangeIter &lt;: Iterator&lt;Int64&gt; {<br \/>\n    var current: Int64<br \/>\n    let end: Int64<\/p>\n<p>    init(start: Int64, end: Int64) {<br \/>\n        this.current &#061; start<br \/>\n        this.end &#061; end<br \/>\n    }<\/p>\n<p>    public func next(): Option&lt;Int64&gt; {<br \/>\n        if (current &lt;&#061; end) {<br \/>\n            let v &#061; current<br \/>\n            current&#043;&#043;<br \/>\n            return Some(v)<br \/>\n        }<br \/>\n        return None<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u5bb9\u5668&#xff1a;\u6bcf\u6b21\u88ab\u904d\u5386\u90fd new \u4e00\u4e2a\u65b0\u6e38\u6807<br \/>\nclass IntRange &lt;: Iterable&lt;Int64&gt; {<br \/>\n    let start: Int64<br \/>\n    let end: Int64<\/p>\n<p>    init(start: Int64, end: Int64) {<br \/>\n        this.start &#061; start<br \/>\n        this.end &#061; end<br \/>\n    }<\/p>\n<p>    public func iterator(): Iterator&lt;Int64&gt; {<br \/>\n        return RangeIter(start, end)<br \/>\n    }<br \/>\n}<\/p>\n<p>main(): Int64 {<br \/>\n    for (v in IntRange(1, 5)) {<br \/>\n        print(&#034;${v} &#034;)<br \/>\n    }<br \/>\n    println()<br \/>\n    return 0<br \/>\n}<\/p>\n<p>1 2 3 4 5<\/p>\n<p>\u6807\u51c6\u5e93\u7684 Array\u3001ArrayList\u3001Range\u3001HashMap&#xff08;\u904d\u5386\u952e\u503c\u5bf9&#xff09;\u8d70\u7684\u90fd\u662f\u8fd9\u5957\u534f\u8bae\u3002\u7b2c 6 \u8bfe\u5b66\u7684\u5b57\u7b26\u4e32\u5b57\u8282\u904d\u5386\u548c runes() \u5b57\u7b26\u904d\u5386&#xff0c;\u672c\u8d28\u4e5f\u662f\u8fed\u4ee3\u5668\u3002<\/p>\n<p>&#x1f6ab; \u5982\u679c\u4e00\u4e2a\u7c7b\u5149\u5199\u4e86 iterator() \u65b9\u6cd5\u5374\u4e0d\u58f0\u660e &lt;: Iterable&lt;T&gt;&#xff0c;for-in \u4f1a\u62a5\u9519&#xff1a;the type &#8230; does not implement Iterator\u3002\u4ed3\u9889\u4e0d\u770b&#034;\u65b9\u6cd5\u957f\u5f97\u50cf\u4e0d\u50cf&#034;&#xff0c;\u53ea\u8ba4\u63a5\u53e3\u58f0\u660e\u3002<\/p>\n<hr \/>\n<h3>\u4e94\u3001Iterator \u4e0e Iterable&#xff1a;\u4e00\u6b21\u6027\u6e38\u6807 vs \u53ef\u91cd\u590d\u904d\u5386<\/h3>\n<p>\u8fd9\u662f\u672c\u8282\u8bfe\u6700\u5bb9\u6613\u6df7\u6dc6\u3001\u4e5f\u6700\u5173\u952e\u7684\u4e00\u70b9\u3002\u4e24\u4e2a\u63a5\u53e3\u662f\u5e76\u5217\u5173\u7cfb&#xff0c;\u4e0d\u662f\u7ee7\u627f&#xff08;\u6211\u8bd5\u8fc7\u628a Iterable \u5bf9\u8c61\u8d4b\u7ed9 Iterator \u53d8\u91cf&#xff0c;\u7f16\u8bd1\u5668\u76f4\u63a5 mismatched types&#xff09;\u3002\u5206\u5de5\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>Iterator&lt;T&gt;Iterable&lt;T&gt;<\/tr>\n<tbody>\n<tr>\n<td>\u89d2\u8272<\/td>\n<td>\u6e38\u6807&#xff08;\u6709\u72b6\u6001\u3001\u4f1a\u524d\u8fdb&#xff09;<\/td>\n<td>\u5bb9\u5668&#xff08;\u6570\u636e\u672c\u8eab&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u8981\u5b9e\u73b0\u7684\u65b9\u6cd5<\/td>\n<td>next(): Option&lt;T&gt;<\/td>\n<td>iterator(): Iterator&lt;T&gt;<\/td>\n<\/tr>\n<tr>\n<td>\u80fd\u5426\u91cd\u590d\u904d\u5386<\/td>\n<td>\u4e0d\u80fd&#xff0c;\u8017\u5c3d\u5373\u7a7a<\/td>\n<td>\u80fd&#xff0c;\u6bcf\u6b21\u4ea7\u751f\u65b0\u6e38\u6807<\/td>\n<\/tr>\n<tr>\n<td>\u5178\u578b\u4ee3\u8868<\/td>\n<td>arr.iterator() \u7684\u8fd4\u56de\u503c<\/td>\n<td>\u6570\u7ec4\u3001ArrayList\u3001Range<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5b9e\u6d4b&#034;\u8fed\u4ee3\u5668\u4e00\u6b21\u6027&#034;&#xff1a;<\/p>\n<p>main(): Int64 {<br \/>\n    let arr &#061; [10, 20, 30]<\/p>\n<p>    let it &#061; arr.iterator()<br \/>\n    let n1 &#061; it.fold(0) { acc, _ &#061;&gt; acc &#043; 1 }<br \/>\n    let n2 &#061; it.fold(0) { acc, _ &#061;&gt; acc &#043; 1 }<br \/>\n    println(&#034;\u7b2c\u4e00\u6b21&#xff1a;${n1}&#xff0c;\u7b2c\u4e8c\u6b21&#xff1a;${n2}&#034;)<\/p>\n<p>    \/\/ \u76f4\u63a5\u904d\u5386\u6570\u7ec4&#xff08;Iterable&#xff09;&#xff0c;\u591a\u5c11\u6b21\u90fd\u884c<br \/>\n    let n3 &#061; arr.iterator().fold(0) { acc, _ &#061;&gt; acc &#043; 1 }<br \/>\n    println(&#034;\u91cd\u65b0\u62ff\u4e00\u4e2a\u6e38\u6807&#xff1a;${n3}&#034;)<br \/>\n    return 0<br \/>\n}<\/p>\n<p>\u7b2c\u4e00\u6b21&#xff1a;3&#xff0c;\u7b2c\u4e8c\u6b21&#xff1a;0<br \/>\n\u91cd\u65b0\u62ff\u4e00\u4e2a\u6e38\u6807&#xff1a;3<\/p>\n<p>\u540c\u4e00\u4e2a it \u904d\u5386\u4e00\u904d\u540e\u6e38\u6807\u5df2\u5230\u5c3d\u5934&#xff0c;\u7b2c\u4e8c\u904d\u4ec0\u4e48\u90fd\u6ca1\u6709&#xff08;0 \u4e2a&#xff09;&#xff1b;\u800c\u5411\u6570\u7ec4&#xff08;Iterable&#xff09;\u518d\u8981\u4e00\u4e2a iterator()&#xff0c;\u53c8\u662f\u4e00\u6761\u597d\u6c49\u3002<\/p>\n<p>&#x1f4cc; \u7ecf\u9a8c\u6cd5\u5219&#xff1a;\u81ea\u5df1\u5199\u6570\u636e\u5bb9\u5668&#xff0c;\u5b9e\u73b0 Iterable&#xff1b;\u53ea\u60f3\u751f\u6210\u4e00\u4e32\u503c&#xff08;\u5c24\u5176\u662f\u7b97\u51fa\u6765\u7684\u3001\u65e0\u9650\u7684&#xff09;&#xff0c;\u5b9e\u73b0 Iterator\u3002<\/p>\n<hr \/>\n<h3>\u516d\u3001\u60f0\u6027\u6d41\u6c34\u7ebf&#xff1a;map \/ filter \/ take \/ skip<\/h3>\n<p>\u8fed\u4ee3\u5668\u4e4b\u6240\u4ee5\u597d\u7528&#xff0c;\u662f\u56e0\u4e3a Iterator \u4e0a\u6302\u4e86\u4e00\u4e32\u94fe\u5f0f\u65b9\u6cd5&#xff0c;\u5199\u6cd5\u548c\u7b2c 12 \u8bfe\u7684\u6570\u7ec4 Lambda \u51e0\u4e4e\u4e00\u6837&#xff0c;\u4f46\u8bed\u4e49\u5b8c\u5168\u4e0d\u540c&#xff1a;<\/p>\n<h4>6.1 \u5148\u770b\u6570\u7ec4\u4e0a\u7684\u94fe&#xff1a;\u7acb\u5373\u6c42\u503c<\/h4>\n<p>let nums &#061; [1, 2, 3, 4, 5, 6, 7, 8]<br \/>\nlet r &#061; nums.map { x &#061;&gt; x * 2 }.filter { x &#061;&gt; x &gt; 10 }.take(2)<br \/>\nprintln(&#034;${r}&#034;)<\/p>\n<p>[12, 14]<\/p>\n<p>\u8fd9\u6761\u94fe\u6bcf\u4e00\u6b65\u90fd\u7acb\u523b\u6267\u884c\u5e76\u4ea7\u51fa\u4e00\u4e2a\u65b0\u6570\u7ec4&#xff1a;map \u5148\u9020\u4e00\u4e2a 8 \u5143\u7d20\u6570\u7ec4&#xff0c;filter \u518d\u9020\u4e00\u4e2a&#xff0c;take \u518d\u9020\u4e00\u4e2a\u3002\u6570\u636e\u91cf\u5927\u65f6\u4e2d\u95f4\u6570\u7ec4\u4f1a\u6d6a\u8d39\u5927\u91cf\u5185\u5b58\u3002<\/p>\n<h4>6.2 \u518d\u770b\u8fed\u4ee3\u5668\u4e0a\u7684\u94fe&#xff1a;\u60f0\u6027\u6c42\u503c<\/h4>\n<p>\u53ea\u8981\u5728\u5f00\u5934\u52a0\u4e00\u4e2a .iterator()&#xff0c;\u6574\u6761\u94fe\u7684\u6027\u8d28\u5c31\u53d8\u4e86&#xff1a;<\/p>\n<p>let r2 &#061; nums.iterator()<br \/>\n    .map { x &#061;&gt; x * 2 }<br \/>\n    .filter { x &#061;&gt; x &gt; 10 }<br \/>\n    .take(2)<br \/>\n    .forEach { v &#061;&gt; print(&#034;${v} &#034;) }<\/p>\n<ul>\n<li>map \/ filter \/ take \/ skip \u79f0\u4e3a\u4e2d\u95f4\u64cd\u4f5c&#xff1a;\u5b83\u4eec\u4e0d\u7acb\u523b\u8ba1\u7b97&#xff0c;\u53ea\u662f\u8fd4\u56de\u4e00\u4e2a&#034;\u8bb0\u4f4f\u4e86\u89c4\u5219&#034;\u7684\u65b0\u8fed\u4ee3\u5668&#xff0c;\u50cf\u4e00\u4e32\u6263\u5728\u4e00\u8d77\u7684\u9f7f\u8f6e&#xff1b;<\/li>\n<li>forEach \/ fold \/ any \u7b49\u79f0\u4e3a\u7ec8\u7aef\u64cd\u4f5c&#xff1a;\u53ea\u6709\u8c03\u7528\u5b83\u4eec&#xff0c;\u9f7f\u8f6e\u624d\u771f\u6b63\u8f6c\u52a8&#xff0c;\u5f00\u59cb\u4e00\u4e2a\u4e00\u4e2a\u5730 next() \u62c9\u53d6&#xff1b;<\/li>\n<li>take(2) \u62c9\u591f 2 \u4e2a\u5c31\u505c\u2014\u2014\u4e0a\u6e38\u4e0d\u4f1a\u591a\u7b97\u4e00\u4e2a\u503c\u3002<\/li>\n<\/ul>\n<p>\u7a7a\u53e3\u65e0\u51ed&#xff0c;\u770b\u5b9e\u6d4b\u3002\u5728 map \u91cc\u585e\u4e00\u884c\u6253\u5370\u5f53&#034;\u63a2\u9488&#034;&#xff0c;\u53ea\u53d6 3 \u4e2a\u503c&#xff1a;<\/p>\n<p>main(): Int64 {<br \/>\n    let data &#061; [10, 20, 30, 40, 50]<br \/>\n    let lazyMapped &#061; data.iterator().map { x &#061;&gt;<br \/>\n        println(&#034;  &#8230;\u6b63\u5728\u8ba1\u7b97 ${x}&#034;)<br \/>\n        x * 2<br \/>\n    }<br \/>\n    println(&#034;\u53ea\u53d6\u524d 3 \u4e2a&#xff1a;&#034;)<br \/>\n    lazyMapped.take(3).forEach { v &#061;&gt; println(&#034;\u5f97\u5230 ${v}&#034;) }<br \/>\n    return 0<br \/>\n}<\/p>\n<p>\u53ea\u53d6\u524d 3 \u4e2a&#xff1a;<br \/>\n  &#8230;\u6b63\u5728\u8ba1\u7b97 10<br \/>\n\u5f97\u5230 20<br \/>\n  &#8230;\u6b63\u5728\u8ba1\u7b97 20<br \/>\n\u5f97\u5230 40<br \/>\n  &#8230;\u6b63\u5728\u8ba1\u7b97 30<br \/>\n\u5f97\u5230 60<\/p>\n<p>5 \u4e2a\u6570\u636e&#xff0c;\u53ea\u7b97\u4e86\u524d 3 \u4e2a\u2014\u201440 \u548c 50 \u7684 map \u89c4\u5219\u4e00\u6b21\u90fd\u6ca1\u6267\u884c\u3002\u8fd9\u5c31\u662f\u60f0\u6027&#xff1a;\u7ec8\u7aef\u64cd\u4f5c\u8981\u591a\u5c11&#xff0c;\u4e2d\u95f4\u64cd\u4f5c\u624d\u7b97\u591a\u5c11\u3002\u5982\u679c\u8fd9\u662f 10 GB \u65e5\u5fd7&#xff0c;\u7701\u4e0b\u7684\u5c31\u662f\u5de8\u91cf\u5185\u5b58\u548c\u65f6\u95f4\u3002<\/p>\n<h4>6.3 \u5e38\u7528\u4e2d\u95f4\u64cd\u4f5c<\/h4>\n<table>\n<tr>\u65b9\u6cd5\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>map { x &#061;&gt; &#8230; }<\/td>\n<td>\u9010\u4e2a\u53d8\u6362\u503c\u7684\u7c7b\u578b\/\u5185\u5bb9<\/td>\n<\/tr>\n<tr>\n<td>filter { x &#061;&gt; \u6761\u4ef6 }<\/td>\n<td>\u53ea\u4fdd\u7559\u6ee1\u8db3\u6761\u4ef6\u7684\u503c<\/td>\n<\/tr>\n<tr>\n<td>take(n)<\/td>\n<td>\u53ea\u53d6\u524d n \u4e2a&#xff0c;\u7136\u540e\u7ed3\u675f<\/td>\n<\/tr>\n<tr>\n<td>skip(n)<\/td>\n<td>\u8df3\u8fc7\u524d n \u4e2a&#xff0c;\u4ece\u7b2c n&#043;1 \u4e2a\u5f00\u59cb<\/td>\n<\/tr>\n<tr>\n<td>flatMap { x &#061;&gt; \u8fed\u4ee3\u5668 }<\/td>\n<td>\u4e00\u5bf9\u591a\u5c55\u5f00&#xff0c;\u518d\u62cd\u5e73\u6210\u4e00\u6761\u6d41<\/td>\n<\/tr>\n<tr>\n<td>zip(\u53e6\u4e00\u4e2a\u8fed\u4ee3\u5668)<\/td>\n<td>\u4e24\u6761\u6d41\u914d\u5bf9&#xff0c;\u4ea7\u51fa (a, b) \u5143\u7ec4&#xff0c;\u77ed\u7684\u5230\u5934\u5c31\u7ed3\u675f<\/td>\n<\/tr>\n<tr>\n<td>concat(\u53e6\u4e00\u4e2a\u8fed\u4ee3\u5668)<\/td>\n<td>\u5148\u6d41\u5b8c\u81ea\u5df1&#xff0c;\u518d\u63a5\u4e0a\u6d41\u53e6\u4e00\u4e2a<\/td>\n<\/tr>\n<tr>\n<td>enumerate()<\/td>\n<td>\u7ed9\u6bcf\u4e2a\u503c\u8d34\u4e0a\u4ece 0 \u5f00\u59cb\u7684\u7f16\u53f7&#xff0c;\u4ea7\u51fa (\u4e0b\u6807, \u503c) \u5143\u7ec4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>flatMap \u793a\u4f8b&#xff08;\u6bcf\u4e2a\u503c\u5c55\u5f00\u6210\u4e24\u4e2a&#xff09;&#xff1a;<\/p>\n<p>[1, 2, 3].iterator()<br \/>\n    .flatMap { x &#061;&gt; [x, x * 10].iterator() }<br \/>\n    .forEach { v &#061;&gt; print(&#034;${v} &#034;) }<\/p>\n<p>1 10 2 20 3 30<\/p>\n<p>\u26a0\ufe0f \u5143\u7ec4\u4e0d\u80fd\u76f4\u63a5\u5b57\u7b26\u4e32\u63d2\u503c\u3002zip \/ enumerate \u4ea7\u51fa\u7684\u5143\u7ec4\u5199 &#034;${p}&#034; \u4f1a\u62a5 Tuple &#8230; should implement interface &#039;ToString&#039;&#xff0c;\u8981\u7528\u4e0b\u6807\u53d6\u5206\u91cf&#xff1a;p[0]\u3001p[1]\u3002<\/p>\n<hr \/>\n<h3>\u4e03\u3001\u65e0\u9650\u5e8f\u5217&#xff1a;\u6709\u4e86 take&#xff0c;\u65e0\u7a77\u4e5f\u6562\u904d\u5386<\/h3>\n<p>\u60f0\u6027\u8fed\u4ee3\u5668\u6700\u9707\u64bc\u7684\u7528\u6cd5&#xff1a;\u5e8f\u5217\u53ef\u4ee5\u662f\u65e0\u9650\u7684\u3002\u56e0\u4e3a\u53cd\u6b63\u4f60\u4e0d\u4e3b\u52a8\u62c9&#xff0c;\u5b83\u4e00\u4e2a\u503c\u90fd\u4e0d\u4f1a\u7b97&#xff1b;\u518d\u914d\u5408 take \u8bbe\u597d&#034;\u5b89\u5168\u9600&#034;&#xff0c;\u65e0\u9650\u6d41\u5c31\u53d8\u6210\u4e86&#034;\u60f3\u8981\u591a\u5c11\u53d6\u591a\u5c11&#034;\u3002<\/p>\n<p>\u5b9e\u6d4b\u4e00\u4e2a\u65e0\u9650\u7684\u6590\u6ce2\u90a3\u5951\u6570\u5217\u751f\u6210\u5668&#xff1a;<\/p>\n<p>class Fib &lt;: Iterator&lt;Int64&gt; {<br \/>\n    var a: Int64 &#061; 0<br \/>\n    var b: Int64 &#061; 1<\/p>\n<p>    public func next(): Option&lt;Int64&gt; {<br \/>\n        let v &#061; a<br \/>\n        a &#061; b<br \/>\n        b &#061; v &#043; b<br \/>\n        return Some(v)   \/\/ \u6c38\u8fdc\u8fd4\u56de Some&#xff0c;\u5e8f\u5217\u6ca1\u6709\u5c3d\u5934<br \/>\n    }<br \/>\n}<\/p>\n<p>main(): Int64 {<br \/>\n    print(&#034;\u524d 10 \u4e2a\u6590\u6ce2\u90a3\u5951\u6570&#xff1a;&#034;)<br \/>\n    Fib().take(10).forEach { x &#061;&gt; print(&#034;${x} &#034;) }<br \/>\n    println()<br \/>\n    return 0<br \/>\n}<\/p>\n<p>\u524d 10 \u4e2a\u6590\u6ce2\u90a3\u5951\u6570&#xff1a;0 1 1 2 3 5 8 13 21 34<\/p>\n<p>Fib() \u672c\u8eab\u662f\u65e0\u9650\u7684&#xff0c;\u76f4\u63a5 for (v in Fib()) \u4f1a\u6b7b\u5faa\u73af&#xff1b;\u4f46 take(10) \u62c9\u6ee1 10 \u4e2a\u5c31\u53d1\u51fa\u7ed3\u675f\u4fe1\u53f7&#xff0c;\u7a0b\u5e8f\u5b89\u7136\u65e0\u6059\u3002\u81ea\u7136\u6570\u3001\u7d20\u6570\u6d41\u3001\u968f\u673a\u6570\u6d41\u90fd\u662f\u540c\u4e00\u4e2a\u5957\u8def\u3002<\/p>\n<p>&#x1f6ab; \u4ed3\u9889 1.1.3 \u6ca1\u6709\u751f\u6210\u5668\u8bed\u6cd5\u7cd6\u3002 \u7f51\u4e0a\u770b\u5230\u4ed3\u9889&#xff08;\u6216\u5176\u4ed6\u8bed\u8a00&#xff09;\u6559\u7a0b\u91cc\u5199 sequence&lt;Int64&gt; { yield(1); yield(2) }\u3001\u6216\u5728\u666e\u901a\u51fd\u6570\u91cc\u5199 yield(x) \u5f53\u751f\u6210\u5668\u2014\u2014\u672c\u7248\u672c\u7f16\u8bd1\u5668\u4f1a\u62a5 undeclared identifier &#039;sequence&#039; \/ undeclared identifier &#039;yield&#039;\u3002\u4ed3\u9889\u7684\u505a\u6cd5\u5c31\u662f\u8001\u8001\u5b9e\u5b9e\u5199\u4e00\u4e2a\u5b9e\u73b0 Iterator \u7684\u7c7b&#xff0c;\u628a&#034;\u72b6\u6001&#034;\u653e\u8fdb\u5b57\u6bb5&#xff08;\u6bd4\u5982 Fib \u7684 a\u3001b&#xff09;&#xff0c;\u5728 next() \u91cc\u63a8\u8fdb\u72b6\u6001\u3002\u5570\u55e6\u4e00\u70b9&#xff0c;\u4f46\u903b\u8f91\u5b8c\u5168\u900f\u660e\u3002<\/p>\n<hr \/>\n<h3>\u516b\u3001\u7ec8\u7aef\u64cd\u4f5c\u4e0e API \u901f\u67e5<\/h3>\n<p>\u7ec8\u7aef\u64cd\u4f5c\u4e00\u8c03\u7528&#xff0c;\u6574\u6761\u60f0\u6027\u94fe\u5f00\u59cb\u771f\u6b63\u8fd0\u7b97&#xff0c;\u5e76\u7ed9\u51fa\u4e00\u4e2a\u6700\u7ec8\u7ed3\u679c&#xff08;\u800c\u4e0d\u662f\u53e6\u4e00\u4e2a\u8fed\u4ee3\u5668&#xff09;\u3002\u5747\u5728 1.1.3 \u5b9e\u6d4b&#xff1a;<\/p>\n<table>\n<tr>\u65b9\u6cd5\u8fd4\u56de\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>forEach { x &#061;&gt; &#8230; }<\/td>\n<td>Unit<\/td>\n<td>\u9010\u503c\u6267\u884c\u526f\u4f5c\u7528&#xff08;\u6253\u5370\u3001\u5199\u5165\u6587\u4ef6\u7b49&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>fold(\u521d\u503c) { acc, x &#061;&gt; &#8230; }<\/td>\n<td>\u7d2f\u52a0\u7ed3\u679c<\/td>\n<td>\u6700\u901a\u7528\u7684\u805a\u5408&#xff0c;\u6c42\u548c\/\u8ba1\u6570\/\u62fc\u63a5\u90fd\u9760\u5b83<\/td>\n<\/tr>\n<tr>\n<td>reduce { a, b &#061;&gt; &#8230; }<\/td>\n<td>Option&lt;R&gt;<\/td>\n<td>\u65e0\u521d\u503c\u805a\u5408&#xff0c;\u7a7a\u6d41\u8fd4\u56de None&#xff0c;\u66f4\u5b89\u5168<\/td>\n<\/tr>\n<tr>\n<td>count()<\/td>\n<td>Int64<\/td>\n<td>\u7edf\u8ba1\u5269\u4f59\u5143\u7d20\u4e2a\u6570&#xff08;\u4e0d\u63a5\u53d7\u6761\u4ef6&#xff0c;\u8981\u6761\u4ef6\u8ba1\u6570\u5148 filter&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>any { x &#061;&gt; \u6761\u4ef6 }<\/td>\n<td>Bool<\/td>\n<td>\u662f\u5426\u5b58\u5728\u6ee1\u8db3\u6761\u4ef6\u7684\u503c&#xff08;\u627e\u5230\u5373\u505c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>all { x &#061;&gt; \u6761\u4ef6 }<\/td>\n<td>Bool<\/td>\n<td>\u662f\u5426\u5168\u90e8\u6ee1\u8db3&#xff08;\u9047\u5230\u53cd\u4f8b\u5373\u505c&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>first()<\/td>\n<td>Option&lt;T&gt;<\/td>\n<td>\u7b2c\u4e00\u4e2a\u503c&#xff0c;\u7a7a\u6d41\u4e3a None<\/td>\n<\/tr>\n<tr>\n<td>min() \/ max()<\/td>\n<td>Option&lt;T&gt;<\/td>\n<td>\u6700\u5c0f\/\u6700\u5927\u503c&#xff0c;\u7a7a\u6d41\u4e3a None<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u51e0\u4e2a\u5b9e\u6d4b\u8981\u70b9&#xff1a;<\/p>\n<p>\u2460 \u6761\u4ef6\u8ba1\u6570\u7528 filter(&#8230;).count()&#xff0c;\u56e0\u4e3a count() \u4e0d\u5e26\u53c2\u6570&#xff1a;<\/p>\n<p>let n &#061; [1, 2, 3, 4].iterator().filter { x &#061;&gt; x &gt; 2 }.count()<br \/>\nprintln(&#034;${n}&#034;)   \/\/ 2<\/p>\n<p>\u2461 reduce \/ min \/ max \/ first \u8fd4\u56de Option&#xff0c;\u7a7a\u6d41\u4e0d\u629b\u5f02\u5e38&#xff0c;\u7528 match \u6216 ?? \u515c\u5e95&#xff1a;<\/p>\n<p>match (ArrayList&lt;Int64&gt;().iterator().min()) {<br \/>\n    case Some(v) &#061;&gt; println(&#034;\u6700\u5c0f\u503c ${v}&#034;)<br \/>\n    case None &#061;&gt; println(&#034;\u7a7a\u7684&#xff0c;\u6ca1\u6709\u6700\u5c0f\u503c&#034;)<br \/>\n}<\/p>\n<p>\u7a7a\u7684&#xff0c;\u6ca1\u6709\u6700\u5c0f\u503c<\/p>\n<p>\u2462 \u8fed\u4ee3\u5668\u4e0a\u6ca1\u6709 toArray() \/ toArrayList()&#xff0c;\u60f3\u628a\u60f0\u6027\u94fe\u7684\u7ed3\u679c\u6536\u6210\u96c6\u5408&#xff0c;\u624b\u52a8\u63a5\u8fdb ArrayList&#xff08;forEach \u91cc\u8c03\u7528\u7684\u662f\u5bb9\u5668\u65b9\u6cd5&#xff0c;\u4e0d\u6355\u83b7\u5916\u5c42 var&#xff0c;\u5408\u6cd5&#xff09;&#xff1a;<\/p>\n<p>let list &#061; ArrayList&lt;Int64&gt;()<br \/>\nFib().take(5).forEach { x &#061;&gt; list.add(x) }<br \/>\nlet arr &#061; list.toArray()<br \/>\nprintln(&#034;${arr}&#034;)   \/\/ [0, 1, 1, 2, 3]<\/p>\n<p>\u2463 \u4e00\u5f20&#034;\u522b\u5199\u9519\u540d\u5b57&#034;\u5bf9\u7167\u8868&#xff08;\u5de6\u5217\u5728 1.1.3 \u8fed\u4ee3\u5668\u4e0a\u4e0d\u5b58\u5728&#xff0c;\u53f3\u5217\u624d\u662f\u5bf9\u7684&#xff09;&#xff1a;<\/p>\n<table>\n<tr>\u522b\u5199\u6b63\u786e\u5199\u6cd5<\/tr>\n<tbody>\n<tr>\n<td>iter.drop(n)<\/td>\n<td>iter.skip(n)<\/td>\n<\/tr>\n<tr>\n<td>iter1.chain(iter2)<\/td>\n<td>iter1.concat(iter2)<\/td>\n<\/tr>\n<tr>\n<td>iter.sum()<\/td>\n<td>iter.fold(0) { a, b &#061;&gt; a &#043; b }<\/td>\n<\/tr>\n<tr>\n<td>iter.toArray()<\/td>\n<td>forEach \u624b\u52a8\u6536\u96c6\u8fdb ArrayList&#xff0c;\u518d toArray()<\/td>\n<\/tr>\n<tr>\n<td>iter.count { x &#061;&gt; &#8230; }<\/td>\n<td>iter.filter { x &#061;&gt; &#8230; }.count()<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u4e5d\u3001CIDE \u5b9e\u64cd&#xff1a;\u6c14\u6e29\u76d1\u6d4b\u6570\u636e\u6d41<\/h3>\n<h4>9.1 \u7f16\u5199\u7a0b\u5e8f<\/h4>\n<p>\u7efc\u5408\u8fd0\u7528\u672c\u8282\u8bfe\u5168\u90e8\u8981\u7d20&#xff1a;\u81ea\u5b9a\u4e49\u65e0\u9650\u8fed\u4ee3\u5668 &#043; \u81ea\u5b9a\u4e49 Iterable \u5bb9\u5668\u3001\u60f0\u6027 filter\/map\/take\u3001fold\/reduce \u805a\u5408\u3001any\/all \u5224\u5b9a\u3001min\/max \u5b89\u5168\u53d6\u503c\u3001enumerate \u7f16\u53f7\u3001concat \u62fc\u63a5\u3002<\/p>\n<p>\u573a\u666f&#xff1a;\u6c14\u8c61\u7ad9\u4e00\u5468\u6c14\u6e29\u8bfb\u6570&#xff0c;\u7528 -99 \u6807\u8bb0\u4f20\u611f\u5668\u7f3a\u5931\u7684\u6570\u636e\u3002\u9700\u8981\u8fc7\u6ee4\u7f3a\u5931\u503c\u5e76\u5b8c\u6210\u7edf\u8ba1&#xff1b;\u53e6\u7528\u4e00\u4e2a\u65e0\u9650\u81ea\u7136\u6570\u6d41\u6f14\u793a&#034;\u65e0\u9650\u6570\u636e &#043; take \u5b89\u5168\u9600&#034;\u3002<\/p>\n<p>package WeatherIter<\/p>\n<p>import std.collection.*<\/p>\n<p>\/\/ \u2460 \u65e0\u9650\u8fed\u4ee3\u5668&#xff1a;\u4ece 1 \u5f00\u59cb\u7684\u81ea\u7136\u6570\u6d41<br \/>\nclass Naturals &lt;: Iterator&lt;Int64&gt; {<br \/>\n    var n: Int64 &#061; 1<br \/>\n    public func next(): Option&lt;Int64&gt; {<br \/>\n        let v &#061; n<br \/>\n        n&#043;&#043;<br \/>\n        return Some(v)<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u2461 \u5bb9\u5668&#xff1a;\u4e00\u5468\u6c14\u6e29\u8bfb\u6570<br \/>\nclass WeeklyTemps &lt;: Iterable&lt;Int64&gt; {<br \/>\n    let data: Array&lt;Int64&gt;<br \/>\n    init(data: Array&lt;Int64&gt;) { this.data &#061; data }<br \/>\n    public func iterator(): Iterator&lt;Int64&gt; {<br \/>\n        return TempIter(data)<br \/>\n    }<br \/>\n}<\/p>\n<p>\/\/ \u5bb9\u5668\u4e13\u5c5e\u6e38\u6807<br \/>\nclass TempIter &lt;: Iterator&lt;Int64&gt; {<br \/>\n    let data: Array&lt;Int64&gt;<br \/>\n    var i: Int64 &#061; 0<br \/>\n    init(data: Array&lt;Int64&gt;) { this.data &#061; data }<br \/>\n    public func next(): Option&lt;Int64&gt; {<br \/>\n        if (i &lt; data.size) {<br \/>\n            let v &#061; data[i]<br \/>\n            i&#043;&#043;<br \/>\n            return Some(v)<br \/>\n        }<br \/>\n        return None<br \/>\n    }<br \/>\n}<\/p>\n<p>main(): Int64 {<br \/>\n    \/\/ \u2014\u2014 \u65e0\u9650\u6d41\u4e5f\u6562\u7528&#xff0c;take \u515c\u5e95 \u2014\u2014<br \/>\n    print(&#034;\u524d 10 \u4e2a\u5e73\u65b9\u6570&#xff1a;&#034;)<br \/>\n    Naturals().map { x &#061;&gt; x * x }.take(10).forEach { v &#061;&gt; print(&#034;${v} &#034;) }<br \/>\n    println()<\/p>\n<p>    \/\/ \u2014\u2014 \u771f\u5b9e\u5bb9\u5668\u7684\u60f0\u6027\u6d41\u6c34\u7ebf \u2014\u2014<br \/>\n    let week &#061; WeeklyTemps([21, -99, 23, -99, 25, 22, 30])<\/p>\n<p>    \/\/ \u4e2a\u6570\u4e0e\u603b\u548c&#xff08;count \u4e0d\u63a5\u53d7\u6761\u4ef6&#xff0c;\u5148 filter&#xff09;<br \/>\n    let count &#061; week.iterator().filter { t &#061;&gt; t !&#061; -99 }.count()<br \/>\n    let total &#061; week.iterator().filter { t &#061;&gt; t !&#061; -99 }.fold(0) { a, b &#061;&gt; a &#043; b }<br \/>\n    println(&#034;\u6709\u6548\u5929\u6570&#xff1a;${count}&#xff0c;\u5e73\u5747\u6c14\u6e29&#xff1a;${total \/ count}\u2103&#034;)<\/p>\n<p>    \/\/ reduce \u65e0\u521d\u503c\u6c42\u548c&#xff1a;\u7a7a\u6d41\u5929\u7136\u5f97\u5230 None<br \/>\n    let valid &#061; week.iterator().filter { t &#061;&gt; t !&#061; -99 }<br \/>\n    match (valid.reduce { a, b &#061;&gt; a &#043; b }) {<br \/>\n        case Some(s) &#061;&gt; println(&#034;reduce \u603b\u548c&#xff1a;${s}&#034;)<br \/>\n        case None &#061;&gt; println(&#034;\u6ca1\u6709\u6709\u6548\u8bfb\u6570&#034;)<br \/>\n    }<\/p>\n<p>    \/\/ \u5224\u5b9a\u7c7b\u7ec8\u7aef\u64cd\u4f5c<br \/>\n    println(&#034;\u662f\u5426\u5168\u90e8\u9ad8\u4e8e 20\u2103&#xff1a;${week.iterator().filter { t &#061;&gt; t !&#061; -99 }.all { t &#061;&gt; t &gt; 20 }}&#034;)<br \/>\n    println(&#034;\u662f\u5426\u51fa\u73b0\u8fc7 30\u2103&#xff1a;${week.iterator().any { t &#061;&gt; t &#061;&#061; 30 }}&#034;)<\/p>\n<p>    \/\/ \u6700\u9ad8\u6e29&#xff1a;max() \u8fd4\u56de Option&#xff0c;\u7528 ?? \u515c\u5e95<br \/>\n    println(&#034;\u6700\u9ad8\u6e29&#xff1a;${week.iterator().filter { t &#061;&gt; t !&#061; -99 }.max() ?? -1}\u2103&#034;)<\/p>\n<p>    \/\/ \u5e26\u7f16\u53f7\u5c55\u793a\u524d 3 \u4e2a\u6709\u6548\u8bfb\u6570&#xff08;\u5143\u7ec4\u7528 p[0]\/p[1] \u53d6\u503c&#xff09;<br \/>\n    print(&#034;\u524d 3 \u4e2a\u6709\u6548\u8bfb\u6570&#xff1a;&#034;)<br \/>\n    week.iterator().filter { t &#061;&gt; t !&#061; -99 }.take(3).enumerate().forEach { p &#061;&gt;<br \/>\n        print(&#034;\u7b2c${p[0] &#043; 1}\u5929&#061;${p[1]}\u2103 &#034;)<br \/>\n    }<br \/>\n    println()<\/p>\n<p>    \/\/ concat \u62fc\u63a5\u4e24\u5468\u6570\u636e<br \/>\n    let week2 &#061; WeeklyTemps([19, 20])<br \/>\n    print(&#034;\u4e24\u5468\u8fde\u8bfb\u524d 4 \u4e2a&#xff1a;&#034;)<br \/>\n    week.iterator().concat(week2.iterator()).take(4).forEach { v &#061;&gt; print(&#034;${v} &#034;) }<br \/>\n    println()<\/p>\n<p>    return 0<br \/>\n}<\/p>\n<h4>9.2 \u8fd0\u884c\u4e0e\u9a8c\u8bc1<\/h4>\n<p>\u524d 10 \u4e2a\u5e73\u65b9\u6570&#xff1a;1 4 9 16 25 36 49 64 81 100<br \/>\n\u6709\u6548\u5929\u6570&#xff1a;5&#xff0c;\u5e73\u5747\u6c14\u6e29&#xff1a;24\u2103<br \/>\nreduce \u603b\u548c&#xff1a;121<br \/>\n\u662f\u5426\u5168\u90e8\u9ad8\u4e8e 20\u2103&#xff1a;true<br \/>\n\u662f\u5426\u51fa\u73b0\u8fc7 30\u2103&#xff1a;true<br \/>\n\u6700\u9ad8\u6e29&#xff1a;30\u2103<br \/>\n\u524d 3 \u4e2a\u6709\u6548\u8bfb\u6570&#xff1a;\u7b2c1\u5929&#061;21\u2103 \u7b2c2\u5929&#061;23\u2103 \u7b2c3\u5929&#061;25\u2103<br \/>\n\u4e24\u5468\u8fde\u8bfb\u524d 4 \u4e2a&#xff1a;21 -99 23 -99<\/p>\n<p>\u5173\u952e\u70b9\u89e3\u8bfb&#xff1a;<\/p>\n<ul>\n<li>Naturals \u6c38\u8fdc\u8fd4\u56de Some&#xff0c;\u662f\u771f\u6b63\u7684\u65e0\u9650\u6d41&#xff1b;take(10) \u50cf\u95f8\u95e8&#xff0c;\u62c9\u591f 10 \u4e2a\u5c31\u5173&#xff0c;map \u4e0d\u4f1a\u88ab\u6267\u884c\u7b2c 11 \u6b21\u3002<\/li>\n<li>WeeklyTemps \u662f\u5bb9\u5668&#xff08;Iterable&#xff09;&#xff0c;\u6301\u6709\u539f\u59cb\u6570\u7ec4&#xff1b;\u6bcf\u6b21 iterator() \u90fd new \u4e00\u4e2a TempIter&#xff0c;\u6240\u4ee5\u4e0b\u9762\u80fd\u5bf9\u540c\u4e00\u5468\u6570\u636e\u53cd\u590d\u505a 5 \u6b21\u7edf\u8ba1&#xff0c;\u4e92\u4e0d\u5e72\u6270\u3002<\/li>\n<li>-99 \u7684\u7f3a\u5931\u503c\u7edf\u4e00\u5728 filter \u9636\u6bb5\u5254\u9664&#xff0c;\u540e\u7eed\u6240\u6709\u7edf\u8ba1\u62ff\u5230\u7684\u90fd\u662f\u5e72\u51c0\u6570\u636e\u2014\u2014\u8fd9\u6b63\u662f\u6d41\u6c34\u7ebf\u7684\u4ef7\u503c&#xff1a;\u8fc7\u6ee4\u903b\u8f91\u53ea\u5199\u4e00\u6b21\u3002<\/li>\n<li>max() \u8fd4\u56de Option&lt;Int64&gt;&#xff0c;?? -1 \u5728\u5168\u7a7a\u65f6\u515c\u5e95&#xff0c;\u7edd\u4e0d\u4f1a\u629b\u5f02\u5e38\u3002<\/li>\n<li>enumerate() \u4ea7\u51fa\u5143\u7ec4&#xff0c;\u5fc5\u987b p[0]\u3001p[1] \u53d6\u5206\u91cf\u3002<\/li>\n<\/ul>\n<p>\u53ef\u4ee5\u81ea\u5df1\u52a8\u624b\u6539&#xff1a;<\/p>\n<ul>\n<li>\u628a take(10) \u6539\u6210 take(20)&#xff0c;\u786e\u8ba4\u5e73\u65b9\u6570\u7ee7\u7eed\u6b63\u786e\u4ea7\u51fa\u3001\u4e14\u7a0b\u5e8f\u6b63\u5e38\u9000\u51fa&#xff1b;<\/li>\n<li>\u628a\u5468\u6570\u636e\u6539\u6210\u5168 -99&#xff0c;\u89c2\u5bdf reduce \u8d70 None \u5206\u652f\u3001max() \u6253\u5370\u515c\u5e95\u503c -1&#xff1b;<\/li>\n<li>\u7528 fold \u8ba1\u7b97\u6709\u6548\u6c14\u6e29\u7684\u5e73\u5747\u503c&#xff08;\u63d0\u793a&#xff1a;\u5148\u6c42\u548c\u3001\u518d\u9664\u4ee5 count&#xff0c;\u6ce8\u610f\u6574\u6570\u9664\u6cd5&#xff09;\u3002<\/li>\n<\/ul>\n<h4>9.3 \u7528\u8c03\u8bd5\u5668\u89c2\u5bdf\u60f0\u6027\u6c42\u503c<\/h4>\n<li>\u5728 Naturals \u7684 next() \u91cc let v &#061; n \u4e00\u884c\u6253\u65ad\u70b9&#xff0c;Shift &#043; F9 \u542f\u52a8\u8c03\u8bd5&#xff1b;<\/li>\n<li>\u5355\u6b65\u89c2\u5bdf&#xff1a;take(10) \u9a71\u52a8\u4e0b&#xff0c;next() \u6070\u597d\u88ab\u8c03\u7528 10 \u6b21&#xff0c;\u7b2c 11 \u6b21\u6c38\u8fdc\u4e0d\u4f1a\u53d1\u751f\u2014\u2014\u4eb2\u773c\u786e\u8ba4&#034;\u7ec8\u7aef\u64cd\u4f5c\u8981\u591a\u5c11\u624d\u7b97\u591a\u5c11&#034;&#xff1b;<\/li>\n<li>\u5728 TempIter.next() \u6253\u65ad\u70b9&#xff0c;\u89c2\u5bdf filter \u5254\u9664 -99 \u65f6\u6e38\u6807\u5982\u4f55&#034;\u591a\u8d70\u4e00\u6b65&#034;\u624d\u5410\u51fa\u4e00\u4e2a\u6709\u6548\u503c&#xff1b;<\/li>\n<li>\u5c55\u5f00 Variables \u9762\u677f\u91cc\u7684 this&#xff0c;\u5bf9\u6bd4\u6bcf\u6b21 iterator() \u4ea7\u751f\u7684 TempIter \u7684 i \u90fd\u662f\u72ec\u7acb\u4ece 0 \u5f00\u59cb\u7684\u3002<\/li>\n<p>\u8c03\u8bd5\u7ed3\u675f\u70b9\u505c\u6b62\u6309\u94ae\u3002<\/p>\n<hr \/>\n<h3>\u5341\u3001\u5e38\u89c1\u95ee\u9898 FAQ<\/h3>\n<p>Q1&#xff1a;\u8fed\u4ee3\u5668\u548c\u6570\u7ec4\u904d\u5386&#xff0c;\u65e5\u5e38\u5199\u4ee3\u7801\u8be5\u7528\u54ea\u4e2a&#xff1f; \u6570\u636e\u5df2\u7ecf\u5728\u6570\u7ec4\u91cc\u3001\u4e14\u8981\u591a\u6b21\u4f7f\u7528&#xff0c;\u76f4\u63a5\u904d\u5386\u6570\u7ec4&#xff08;\u6700\u7b80\u5355&#xff09;\u3002\u8fed\u4ee3\u5668\u7684\u4ef7\u503c\u5728\u4e09\u79cd\u60c5\u51b5&#xff1a;\u6570\u636e\u91cf\u5f88\u5927\/\u65e0\u9650\u3001\u6570\u636e\u662f\u8fb9\u4ea7\u751f\u8fb9\u5904\u7406\u7684\u3001\u60f3\u628a\u591a\u4e2a\u53d8\u6362\u4e32\u6210\u4e00\u6761\u4e0d\u4ea7\u751f\u4e2d\u95f4\u96c6\u5408\u7684\u6d41\u6c34\u7ebf\u3002<\/p>\n<p>Q2&#xff1a;Iterator \u548c Iterable \u5230\u5e95\u600e\u4e48\u9009&#xff1f; \u4f60\u5728\u63cf\u8ff0&#034;\u4e00\u4e2a\u6570\u636e\u96c6\u5408&#034;&#xff08;\u80fd\u88ab\u53cd\u590d\u904d\u5386&#xff09;\u2192 \u5b9e\u73b0 Iterable&#xff0c;\u914d\u4e00\u4e2a\u6e38\u6807\u7c7b&#xff1b;\u4f60\u5728\u63cf\u8ff0&#034;\u4e00\u4e32\u6309\u89c4\u5219\u751f\u6210\u7684\u503c&#034;&#xff08;\u5c24\u5176\u662f\u7b97\u51fa\u6765\u7684\u3001\u65e0\u9650\u7684\u3001\u4e00\u6b21\u6027\u7684&#xff09;\u2192 \u76f4\u63a5\u5b9e\u73b0 Iterator\u3002<\/p>\n<p>Q3&#xff1a;\u4e3a\u4ec0\u4e48\u6211\u7684\u7c7b\u5199\u4e86 iterator() \u65b9\u6cd5&#xff0c;for-in \u8fd8\u662f\u62a5\u9519&#xff1f; \u5149\u6709\u65b9\u6cd5\u4e0d\u591f&#xff0c;\u5fc5\u987b\u5728\u7c7b\u58f0\u660e\u91cc\u5199 &lt;: Iterable&lt;T&gt;\u3002\u4ed3\u9889\u7684 for-in \u53ea\u8ba4\u63a5\u53e3&#xff0c;\u4e0d\u8ba4&#034;\u7ed3\u6784\u4e0a\u6070\u597d\u957f\u8fd9\u6837&#034;\u7684\u9e2d\u5b50\u7c7b\u578b\u3002\u62a5\u9519\u6587\u6848\u662f does not implement Iterator\u3002<\/p>\n<p>Q4&#xff1a;\u4ed3\u9889\u6709 yield \/ \u751f\u6210\u5668\u51fd\u6570\u5417&#xff1f; 1.1.3 \u6ca1\u6709\u3002sequence { } \u5757\u548c\u51fd\u6570\u4f53\u91cc\u7684 yield(x) \u90fd\u4f1a\u62a5&#034;\u672a\u58f0\u660e\u6807\u8bc6\u7b26&#034;\u3002\u751f\u6210\u5e8f\u5217\u7684\u552f\u4e00\u65b9\u5f0f\u662f\u624b\u5199\u5b9e\u73b0 Iterator \u7684\u7c7b&#xff0c;\u7528\u5b57\u6bb5\u4fdd\u5b58\u72b6\u6001\u3001\u5728 next() \u91cc\u63a8\u8fdb\u3002<\/p>\n<p>Q5&#xff1a;\u4e3a\u4ec0\u4e48 arr.map { &#8230; } \u548c arr.iterator().map { &#8230; } \u5199\u6cd5\u5dee\u4e0d\u591a&#xff0c;\u8981\u5f3a\u8c03\u533a\u522b&#xff1f; \u524d\u8005\u6bcf\u4e00\u6b65\u7acb\u5373\u4ea7\u51fa\u65b0\u6570\u7ec4&#xff08;\u4e2d\u95f4\u7ed3\u679c\u5168\u90e8\u9a7b\u7559\u5185\u5b58&#xff09;&#xff1b;\u540e\u8005\u53ea\u5728\u7ec8\u7aef\u64cd\u4f5c\u65f6\u6309\u9700\u8ba1\u7b97&#xff0c;\u4e0d\u4ea7\u751f\u4e2d\u95f4\u6570\u7ec4\u3002\u6570\u636e\u91cf\u5c0f\u770b\u4e0d\u51fa\u5dee\u522b&#xff0c;\u5904\u7406\u5927\u6587\u4ef6\/\u65e0\u9650\u6d41\u65f6\u662f\u5929\u58e4\u4e4b\u522b\u3002<\/p>\n<p>Q6&#xff1a;\u8fed\u4ee3\u5668\u904d\u5386\u4e00\u904d\u540e\u8fd8\u80fd\u518d\u904d\u5386\u5417&#xff1f; \u540c\u4e00\u4e2a\u8fed\u4ee3\u5668\u5bf9\u8c61\u4e0d\u80fd&#xff0c;\u6e38\u6807\u8017\u5c3d\u540e\u518d\u8c03 next() \u6c38\u8fdc\u662f None\u3002\u4f46 Iterable \u5bb9\u5668\u6bcf\u6b21 iterator() \u90fd\u4f1a\u7ed9\u4f60\u4e00\u4e2a\u65b0\u6e38\u6807&#xff0c;\u53ef\u4ee5\u53cd\u590d\u904d\u5386\u3002\u9700\u8981&#034;\u518d\u6765\u4e00\u904d&#034;\u65f6&#xff0c;\u91cd\u65b0\u8c03\u7528 iterator()\u3002<\/p>\n<p>Q7&#xff1a;zip \/ enumerate \u7684\u7ed3\u679c\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u76f4\u63a5\u6253\u5370&#xff1f; \u5b83\u4eec\u4ea7\u51fa\u7684\u662f\u5143\u7ec4&#xff0c;\u6807\u51c6\u5e93\u7684\u5143\u7ec4\u6ca1\u6709\u5b9e\u73b0 ToString&#xff0c;\u5b57\u7b26\u4e32\u63d2\u503c\u4f1a\u62a5\u9519\u3002\u7528\u4e0b\u6807\u53d6\u5206\u91cf&#xff1a;p[0]\u3001p[1]&#xff0c;\u6216\u8005\u89e3\u6784\u540e\u518d\u6253\u5370\u3002<\/p>\n<p>Q8&#xff1a;\u600e\u4e48\u628a\u8fed\u4ee3\u5668\u7ed3\u679c\u5b58\u56de\u6570\u7ec4&#xff1f; \u8fed\u4ee3\u5668\u4e0a\u6ca1\u6709 toArray()\u3002\u5148\u5efa\u4e00\u4e2a ArrayList&lt;T&gt;()&#xff0c;\u7528 forEach { x &#061;&gt; list.add(x) } \u6536\u96c6&#xff0c;\u518d\u8c03 list.toArray()\u3002<\/p>\n<p>Q9&#xff1a;for-in \u65e0\u9650\u8fed\u4ee3\u5668\u4f1a\u600e\u6837&#xff1f; \u4f1a\u6b7b\u5faa\u73af&#xff08;\u65e0\u9650\u8fed\u4ee3\u5668\u7684 next() \u6c38\u8fdc\u8fd4\u56de Some&#xff09;\u3002\u65e0\u9650\u6d41\u5fc5\u987b\u7528 take(n)\u3001any { \u6761\u4ef6 } \u8fd9\u7c7b\u81ea\u5e26\u7ec8\u6b62\u80fd\u529b\u7684\u64cd\u4f5c\u6d88\u8d39&#xff0c;\u786e\u4fdd\u5b83\u8fdf\u65e9\u4f1a\u505c\u3002<\/p>\n<p>Q10&#xff1a;reduce \u548c fold \u6709\u4ec0\u4e48\u533a\u522b&#xff1f;\u7a7a\u6d41\u4f1a\u5d29\u5417&#xff1f; fold(\u521d\u503c) { &#8230; } \u5fc5\u987b\u7ed9\u521d\u503c&#xff0c;\u7a7a\u6d41\u76f4\u63a5\u8fd4\u56de\u521d\u503c&#xff1b;reduce { &#8230; } \u4e0d\u7ed9\u521d\u503c&#xff0c;\u8fd4\u56de Option&#xff0c;\u7a7a\u6d41\u5f97\u5230 None\u3002\u4e8c\u8005\u90fd\u4e0d\u4f1a\u56e0\u4e3a\u7a7a\u5e8f\u5217\u5d29\u6e83\u2014\u2014\u8fd9\u6bd4\u5f88\u591a\u8bed\u8a00\u629b\u5f02\u5e38\u7684\u8bbe\u8ba1\u66f4\u5b89\u5168\u3002<\/p>\n<hr \/>\n<h3>\u5341\u4e00\u3001\u8bfe\u540e\u7ec3\u4e60<\/h3>\n<li>\u5199\u4e00\u4e2a Countdown &lt;: Iterator&lt;Int64&gt;&#xff0c;\u4ece\u6784\u9020\u53c2\u6570 n \u5f00\u59cb\u5012\u7740\u6570\u6570\u5230 1&#xff0c;\u4e4b\u540e\u8fd4\u56de None\u3002\u7528 for-in \u6253\u5370 Countdown(5)&#xff0c;\u5e94\u8f93\u51fa 5 4 3 2 1\u3002<\/li>\n<li>\u7ed9\u7b2c 1 \u9898\u7684\u5012\u8ba1\u65f6\u63a5\u4e0a\u94fe\u5f0f\u64cd\u4f5c&#xff1a;\u53ea\u4fdd\u7559\u5076\u6570\u3001\u6bcf\u4e2a\u6570\u5e73\u65b9\u3001\u7528 forEach \u6253\u5370\u3002\u9884\u671f\u8f93\u51fa 16 4&#xff08;\u5373 4\u00b2\u30012\u00b2&#xff09;\u3002<\/li>\n<li>\u5199\u4e00\u4e2a\u65e0\u9650\u8fed\u4ee3\u5668 MultiplesOf(k: Int64)&#xff0c;\u4f9d\u6b21\u4ea7\u51fa k \u7684\u6240\u6709\u500d\u6570&#xff08;k\u30012k\u30013k\u2026\u2026&#xff09;\u3002\u7528 take(5) \u5b89\u5168\u5730\u53d6\u51fa 3 \u7684\u524d 5 \u4e2a\u500d\u6570\u5e76\u6253\u5370\u3002<\/li>\n<li>\u7528 fold \u5b9e\u73b0\u4e00\u4e2a\u51fd\u6570&#xff0c;\u63a5\u6536\u4e00\u4e2a Iterator&lt;Int64&gt;&#xff0c;\u8fd4\u56de\u5176\u4e2d\u6b63\u6570\u7684\u5e73\u5747\u503c&#xff08;\u63d0\u793a&#xff1a;\u53ef\u4ee5 fold \u51fa\u4e00\u4e2a&#034;\u4e2a\u6570&#043;\u603b\u548c&#034;\u7684\u4e8c\u5143\u7ec4&#xff0c;\u5143\u7ec4\u5b57\u6bb5\u7528 [0]\u3001[1] \u8bbf\u95ee&#xff1b;\u6ce8\u610f\u7a7a\u6d41\u9664\u96f6&#xff0c;\u7528 match \u5904\u7406&#xff09;\u3002<\/li>\n<li>\u7efc\u5408&#xff1a;\u5b9a\u4e49\u4e00\u4e2a Sentence \u5bb9\u5668\u5b9e\u73b0 Iterable&lt;String&gt;&#xff08;\u5185\u90e8\u7528\u4e00\u4e2a Array&lt;String&gt; \u5b58\u5355\u8bcd&#xff09;&#xff0c;\u5199\u4e13\u5c5e\u6e38\u6807\u7c7b\u3002\u7136\u540e\u7528\u8fed\u4ee3\u5668\u94fe\u5b8c\u6210&#xff1a;\u8fc7\u6ee4\u6389\u957f\u5ea6\u5c0f\u4e8e 3 \u7684\u5355\u8bcd\u3001enumerate \u7f16\u53f7\u3001\u53ea\u53d6\u524d 3 \u4e2a\u3001\u6309 #\u7f16\u53f7:\u5355\u8bcd \u7684\u683c\u5f0f\u6253\u5370\u3002<\/li>\n<hr \/>\n<h3>\u4e0b\u8282\u9884\u544a<\/h3>\n<p>\u51fd\u6570\u5f0f\u6a21\u5757&#xff08;11&#xff5e;14 \u8bfe&#xff09;\u5230\u6b64\u6536\u5b98&#xff1a;\u4ece\u547d\u540d\u51fd\u6570\u3001\u533f\u540d Lambda\u3001\u95ed\u5305\u6355\u83b7&#xff0c;\u5230\u4eca\u5929\u6309\u9700\u53d6\u503c\u7684\u8fed\u4ee3\u5668&#xff0c;\u4f60\u5df2\u7ecf\u80fd\u7528&#034;\u503c &#043; \u51fd\u6570&#034;\u8868\u8fbe\u76f8\u5f53\u590d\u6742\u7684\u903b\u8f91\u4e86\u3002\u4f46\u5199\u5927\u578b\u7a0b\u5e8f\u8fd8\u9700\u8981\u53e6\u4e00\u5957\u7ec4\u7ec7\u4ee3\u7801\u7684\u6b66\u5668\u2014\u2014\u628a\u6570\u636e\u548c\u64cd\u4f5c\u6570\u636e\u7684\u65b9\u6cd5\u7ed1\u5728\u4e00\u8d77\u3002\u7b2c 15 \u8bfe \u7ed3\u6784\u4f53 struct \u4e0e\u7c7b class \u6b63\u5f0f\u8fdb\u5165\u9762\u5411\u5bf9\u8c61\u4e16\u754c&#xff1a;\u503c\u7c7b\u578b\u4e0e\u5f15\u7528\u7c7b\u578b\u7684\u6839\u672c\u5dee\u5f02\u3001\u4ec0\u4e48\u65f6\u5019\u8be5\u7528\u8c01\u3001init \u6784\u9020\u51fd\u6570\u7684\u5b8c\u6574\u89c4\u5219\u3002\u6211\u4eec\u4e0b\u8282\u8bfe\u89c1&#xff01;<\/p>\n<hr \/>\n<p>\u7cfb\u5217\u8bf4\u660e&#xff1a;\u672c\u7cfb\u5217\u57fa\u4e8e Windows \u5e73\u53f0 &#043; CIDE &#043; \u4ed3\u9889 SDK&#xff08;1.1.3&#xff09;\u7f16\u5199&#xff0c;\u6240\u6709\u4ee3\u7801\u5747\u5df2\u5b9e\u9645\u7f16\u8bd1\u8fd0\u884c\u901a\u8fc7\u3002\u5982\u9047 SDK \u7248\u672c\u5dee\u5f02\u5bfc\u81f4\u7684\u7ec6\u8282\u51fa\u5165&#xff08;\u4f8b\u5982\u65b0\u7248\u672c\u8865\u5145\u4e86 yield \u751f\u6210\u5668\u8bed\u6cd5\u3001\u4e3a\u8fed\u4ee3\u5668\u589e\u52a0\u4e86 toArray() \u7b49&#xff09;&#xff0c;\u4ee5\u4f60\u672c\u5730\u7248\u672c\u4e3a\u51c6&#xff0c;\u6b22\u8fce\u8bc4\u8bba\u533a\u4ea4\u6d41\u3002<\/p>\n<hr \/>\n<h3>&#x1f4ac; \u9047\u5230\u95ee\u9898&#xff1f;\u626b\u7801\u8054\u7cfb\u4f5c\u8005<\/h3>\n<p>\u8ddf\u7740\u8bfe\u7a0b\u7ec3\u4e60\u65f6&#xff0c;\u5982\u679c\u5728 SDK \u5b89\u88c5\u3001\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u3001\u7f16\u8bd1\u62a5\u9519\u6216\u8c03\u8bd5\u4e0a\u5361\u4f4f&#xff0c;\u6b22\u8fce\u626b\u7801\u52a0\u4f5c\u8005\u4f01\u4e1a\u5fae\u4fe1\u76f4\u63a5\u54a8\u8be2&#xff08;\u8bf7\u5907\u6ce8&#034;\u4ed3\u9889\u8bfe\u7a0b&#034;&#xff09;&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260923014042-6ab32e1a85529.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u79bb\u7ebf\u73af\u5883\u4e0b\u56fe\u7247\u53ef\u80fd\u52a0\u8f7d\u4e0d\u51fa\u6765&#xff0c;\u4e5f\u53ef\u4ee5\u5728 CIDE \u83dc\u5355 Help \u25b8 \u8054\u7cfb\u4f5c\u8005 \/ Contact \u4e2d\u67e5\u770b\u540c\u4e00\u5f20\u4e8c\u7ef4\u7801&#xff08;\u5e94\u7528\u5185\u7f6e\u515c\u5e95\u56fe&#xff0c;\u65e0\u9700\u8054\u7f51&#xff09;\u3002<\/p>\n<hr \/>\n<h3>&#x1f4e5; \u5de5\u5177\u4e0b\u8f7d<\/h3>\n<p>\u672c\u7cfb\u5217\u5168\u7a0b\u4f7f\u7528\u7684\u4ed3\u9889 IDE \u2014\u2014 CIDE&#xff08;\u514d\u8d39\u5f00\u6e90\u3001\u793e\u533a\u7248&#xff09;&#xff1a;<\/p>\n<ul>\n<li>GitCode \u4ed3\u5e93 \/ \u5b89\u88c5\u5305\u4e0b\u8f7d&#xff1a;https:\/\/gitcode.com\/wp_upala\/cide<\/li>\n<li>\u6253\u5f00\u9875\u9762\u540e\u8fdb\u5165 \u53d1\u884c\u7248&#xff08;Releases&#xff09;&#xff0c;\u4e24\u79cd\u5305\u4efb\u9009\u5176\u4e00&#xff1a;\n<ul>\n<li>\u5b89\u88c5\u7248&#xff1a;\u4e0b\u8f7d CIDE-&lt;\u7248\u672c&gt;-x64-Setup.exe&#xff0c;\u53cc\u51fb\u5b89\u88c5&#xff0c;\u9002\u5408\u65e5\u5e38\u957f\u671f\u4f7f\u7528&#xff1b;<\/li>\n<li>\u514d\u5b89\u88c5\u7248&#xff08;Portable&#xff09;&#xff1a;\u4e0b\u8f7d CIDE-&lt;\u7248\u672c&gt;-x64-Portable.zip&#xff0c;\u89e3\u538b\u5230\u4efb\u610f\u76ee\u5f55\u5373\u7528&#xff0c;\u4e0d\u5199\u6ce8\u518c\u8868\u3001\u4e0d\u7559\u5b89\u88c5\u75d5\u8ff9&#xff0c;\u62f7\u5230 U \u76d8\u4e5f\u80fd\u5728\u522b\u7684\u7535\u8111\u76f4\u63a5\u8fd0\u884c&#xff08;\u5305\u5185\u9644\u300a\u4f7f\u7528\u8bf4\u660e.txt\u300b&#xff09;\u3002\u9002\u5408\u5148\u8bd5\u7528\u3001\u6216\u5728\u53d7\u9650\u7535\u8111\u4e0a\u5b66\u4e60\u672c\u7cfb\u5217\u8bfe\u7a0b\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u4ed3\u9889 SDK \u8bf7\u524d\u5f80\u4ed3\u9889\u7f16\u7a0b\u8bed\u8a00\u5b98\u7f51\u4e0b\u8f7d&#xff1a;https:\/\/cangjie-lang.cn<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c14\u8bfe\u3011\u8fed\u4ee3\u5668 Iterator \u4e0e\u60f0\u6027\u5e8f\u5217 \u7b2c 13 \u8bfe\u7528\u95ed\u5305\u505a\u51fa\u4e86\\&#8221;\u80fd\u8bb0\u4f4f\u72b6\u6001\u7684\u51fd\u6570\\&#8221;&#xff0c;\u8fd9\u8282\u8bfe\u89e3\u51b3\u4e00\u4e2a\u66f4\u5b9e\u9645\u7684\u95ee\u9898&#xff1a;\u60f3\u9010\u4e2a\u4ea7\u51fa\u4e00\u7cfb\u5217\u503c\u2014\u2014\u5927\u6587\u4ef6\u7684\u9010\u884c\u8bfb\u53d6\u3001\u4f20\u611f\u5668\u6e90\u6e90\u4e0d\u65ad\u7684\u8bfb\u6570\u3001\u751a\u81f3\u6590\u6ce2\u90a3\u5951\u90a3\u6837\u65e0\u7a77\u65e0\u5c3d\u7684\u6570\u5217\u2014\u2014\u96be\u9053\u90fd\u8981\u5148\u4e00\u53e3\u6c14\u7b97\u5b8c\u585e\u8fdb\u6570\u7ec4&#xff1f;\u5f53\u7136\u4e0d\u662f\u3002\u4ed3\u9889\u7684\u7b54\u6848\u662f\u8fed\u4ee3\u5668&#xff08;Iterator&#xff09;&#xff1a;\u7528\u4e00\u4e2a next() \u65b9\u6cd5\u6309\u9700\u53d6\u503c&#xff0c;\u7528\u591a\u5c11\u7b97\u591a\u5c11\u3002 \u672c\u6587\u6240\u6709\u4ee3\u7801<\/p>\n","protected":false},"author":2,"featured_media":109077,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[70,190,227],"topic":[],"class_list":["post-109078","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-ide","tag-190","tag-227"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c14\u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/109078.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c14\u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c14\u8bfe\u3011\u8fed\u4ee3\u5668 Iterator \u4e0e\u60f0\u6027\u5e8f\u5217 \u7b2c 13 \u8bfe\u7528\u95ed\u5305\u505a\u51fa\u4e86&quot;\u80fd\u8bb0\u4f4f\u72b6\u6001\u7684\u51fd\u6570&quot;&#xff0c;\u8fd9\u8282\u8bfe\u89e3\u51b3\u4e00\u4e2a\u66f4\u5b9e\u9645\u7684\u95ee\u9898&#xff1a;\u60f3\u9010\u4e2a\u4ea7\u51fa\u4e00\u7cfb\u5217\u503c\u2014\u2014\u5927\u6587\u4ef6\u7684\u9010\u884c\u8bfb\u53d6\u3001\u4f20\u611f\u5668\u6e90\u6e90\u4e0d\u65ad\u7684\u8bfb\u6570\u3001\u751a\u81f3\u6590\u6ce2\u90a3\u5951\u90a3\u6837\u65e0\u7a77\u65e0\u5c3d\u7684\u6570\u5217\u2014\u2014\u96be\u9053\u90fd\u8981\u5148\u4e00\u53e3\u6c14\u7b97\u5b8c\u585e\u8fdb\u6570\u7ec4&#xff1f;\u5f53\u7136\u4e0d\u662f\u3002\u4ed3\u9889\u7684\u7b54\u6848\u662f\u8fed\u4ee3\u5668&#xff08;Iterator&#xff09;&#xff1a;\u7528\u4e00\u4e2a next() \u65b9\u6cd5\u6309\u9700\u53d6\u503c&#xff0c;\u7528\u591a\u5c11\u7b97\u591a\u5c11\u3002 \u672c\u6587\u6240\u6709\u4ee3\u7801\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/109078.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-23T01:40:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260923014042-6ab32e1a85529.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/109078.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/109078.html\",\"name\":\"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c14\u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-23T01:40:44+00:00\",\"dateModified\":\"2026-09-23T01:40:44+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/109078.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/109078.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/109078.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c14\u8bfe\u3011\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c14\u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/109078.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c14\u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c14\u8bfe\u3011\u8fed\u4ee3\u5668 Iterator \u4e0e\u60f0\u6027\u5e8f\u5217 \u7b2c 13 \u8bfe\u7528\u95ed\u5305\u505a\u51fa\u4e86\"\u80fd\u8bb0\u4f4f\u72b6\u6001\u7684\u51fd\u6570\"&#xff0c;\u8fd9\u8282\u8bfe\u89e3\u51b3\u4e00\u4e2a\u66f4\u5b9e\u9645\u7684\u95ee\u9898&#xff1a;\u60f3\u9010\u4e2a\u4ea7\u51fa\u4e00\u7cfb\u5217\u503c\u2014\u2014\u5927\u6587\u4ef6\u7684\u9010\u884c\u8bfb\u53d6\u3001\u4f20\u611f\u5668\u6e90\u6e90\u4e0d\u65ad\u7684\u8bfb\u6570\u3001\u751a\u81f3\u6590\u6ce2\u90a3\u5951\u90a3\u6837\u65e0\u7a77\u65e0\u5c3d\u7684\u6570\u5217\u2014\u2014\u96be\u9053\u90fd\u8981\u5148\u4e00\u53e3\u6c14\u7b97\u5b8c\u585e\u8fdb\u6570\u7ec4&#xff1f;\u5f53\u7136\u4e0d\u662f\u3002\u4ed3\u9889\u7684\u7b54\u6848\u662f\u8fed\u4ee3\u5668&#xff08;Iterator&#xff09;&#xff1a;\u7528\u4e00\u4e2a next() \u65b9\u6cd5\u6309\u9700\u53d6\u503c&#xff0c;\u7528\u591a\u5c11\u7b97\u591a\u5c11\u3002 \u672c\u6587\u6240\u6709\u4ee3\u7801","og_url":"https:\/\/www.wsisp.com\/helps\/109078.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-23T01:40:44+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260923014042-6ab32e1a85529.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"10 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/109078.html","url":"https:\/\/www.wsisp.com\/helps\/109078.html","name":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c14\u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-23T01:40:44+00:00","dateModified":"2026-09-23T01:40:44+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/109078.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/109078.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/109078.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c14\u8bfe\u3011"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/109078","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=109078"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/109078\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/109077"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=109078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=109078"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=109078"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=109078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}