{"id":6568,"date":"2021-07-18T10:13:34","date_gmt":"2021-07-18T01:13:34","guid":{"rendered":"https:\/\/taki-lab.site\/bocci\/?p=6568"},"modified":"2021-07-18T10:13:37","modified_gmt":"2021-07-18T01:13:37","slug":"%e3%80%90%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3%e3%80%91iterator%e3%83%91%e3%82%bf%e3%83%bc%e3%83%b3","status":"publish","type":"post","link":"https:\/\/taki-lab.site\/bocci\/?p=6568","title":{"rendered":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Iterator\u30d1\u30bf\u30fc\u30f3"},"content":{"rendered":"\n<p>\u540c\u3058\u3088\u3046\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6574\u5217\u3055\u305b\u3066\u7ba1\u7406\u3057\u305f\u3044\u3068\u304d\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30a4\u30e1\u30fc\u30b8\u3068\u3057\u3066\u306fLIST\u306b\u8fd1\u3044\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package org.example.iterator;\r\n\r\npublic interface Iterator {\r\n    public Object next();\r\n    public boolean hasNext();\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package org.example.iterator;\r\n\r\npublic interface Aggregate {\r\n    public Iterator iterator();\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package org.example.iterator;\r\n\r\npublic class ConcreteAggregate implements Aggregate{\r\n    private Object&#91;] objects;\r\n    private int last = 0;\r\n\r\n    public ConcreteAggregate(int maxSize)\r\n    {\r\n        this.objects = new Object&#91;maxSize];\r\n    }\r\n\r\n    public void add(Object object)\r\n    {\r\n        objects&#91;last] = object;\r\n        last++;\r\n    }\r\n\r\n    public Object getItem(int index)\r\n    {\r\n        return objects&#91;index];\r\n    }\r\n\r\n    public int getLast()\r\n    {\r\n        return last;\r\n    }\r\n\r\n    @Override\r\n    public Iterator iterator() {\r\n        return new ConcreteIterator(this);\r\n    }\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package org.example.iterator;\r\n\r\npublic class ConcreteIterator implements Iterator {\r\n    private ConcreteAggregate aggregate;\r\n    private int index;\r\n\r\n    public ConcreteIterator(ConcreteAggregate aggregate)\r\n    {\r\n        this.aggregate = aggregate;\r\n        this.index = 0;\r\n    }\r\n\r\n    @Override\r\n    public Object next() {\r\n        Object object = aggregate.getItem(index);\r\n        index++;\r\n        return object;\r\n    }\r\n\r\n    @Override\r\n    public boolean hasNext() {\r\n        if(index &lt; aggregate.getLast())\r\n        {\r\n            return true;\r\n        }\r\n        else\r\n        {\r\n            return false;\r\n        }\r\n    }\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package org.example.iterator;\r\n\r\npublic class Item {\r\n}\r\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>package org.example.iterator;\r\n\r\npublic class Main {\r\n    public static void main(String&#91;] args)\r\n    {\r\n        ConcreteAggregate aggregate = new ConcreteAggregate(10);\r\n        aggregate.add(new Item());\r\n        aggregate.add(new Item());\r\n        aggregate.add(new Item());\r\n\r\n        Iterator iterator = aggregate.iterator();\r\n        while(iterator.hasNext())\r\n        {\r\n            Item item = (Item)iterator.next();\r\n        }\r\n    }\r\n}\r\n<\/code><\/pre>\n\n\n\n<p>\u307e\u3041\u3001\u3053\u3093\u306a\u30b3\u30fc\u30c9\u66f8\u304b\u306a\u304f\u3066\u3082\u3001\u3059\u3067\u306bIterator\u30af\u30e9\u30b9\u306f\u5b9f\u88c5\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3002<\/p>\n\n\n\n<p>List\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304b\u3089iterator()\u3067\u53d6\u5f97\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u3058\u3088\u3046\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6574\u5217\u3055\u305b\u3066\u7ba1\u7406\u3057\u305f\u3044\u3068\u304d\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002 \u30a4\u30e1\u30fc\u30b8\u3068\u3057\u3066\u306fLIST\u306b\u8fd1\u3044\u3002 \u307e\u3041\u3001\u3053\u3093\u306a\u30b3\u30fc\u30c9\u66f8\u304b\u306a\u304f\u3066\u3082\u3001\u3059\u3067\u306bIterator\u30af\u30e9\u30b9\u306f\u5b9f\u88c5\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3002 List\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304b\u3089iterat &hellip; <a href=\"https:\/\/taki-lab.site\/bocci\/?p=6568\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Iterator\u30d1\u30bf\u30fc\u30f3<\/span> <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":{"om_disable_all_campaigns":false,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[225,3],"tags":[226],"class_list":["post-6568","post","type-post","status-publish","format-standard","hentry","category-225","category-3","tag-226"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8SDbY-1HW","jetpack-related-posts":[{"id":7844,"url":"https:\/\/taki-lab.site\/bocci\/?p=7844","url_meta":{"origin":6568,"position":0},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Observer\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2022\u5e742\u670813\u65e5","format":false,"excerpt":"Observer\u3068\u306f\u76e3\u8996\u8005\u3068\u3044\u3046\u610f\u5473\u3067\u3001\u4f55\u3089\u304b\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u76e3\u8996\u3057\u3066\u5b9f\u884c\u3055\u305b\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u3002 pack\u2026","rel":"","context":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","block_context":{"text":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","link":"https:\/\/taki-lab.site\/bocci\/?cat=225"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4904,"url":"https:\/\/taki-lab.site\/bocci\/?p=4904","url_meta":{"origin":6568,"position":1},"title":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Flyweight\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2021\u5e741\u670815\u65e5","format":false,"excerpt":"Flyweight\u30d1\u30bf\u30fc\u30f3\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\u3002 package org.example.flywe\u2026","rel":"","context":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","block_context":{"text":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","link":"https:\/\/taki-lab.site\/bocci\/?cat=225"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8205,"url":"https:\/\/taki-lab.site\/bocci\/?p=8205","url_meta":{"origin":6568,"position":2},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011state\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2022\u5e744\u670825\u65e5","format":false,"excerpt":"state\u30d1\u30bf\u30fc\u30f3\u306f\u72b6\u614b\u3092\u8868\u3059\u30af\u30e9\u30b9\u3092\u5c0e\u5165\u3059\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3001\u72b6\u614b\u306b\u5fdc\u3058\u305f\u51e6\u7406\u3092\u5b9f\u884c\u3055\u305b\u308b\u30d1\u30bf\u30fc\u30f3\u3067\u3059\u2026","rel":"","context":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","block_context":{"text":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","link":"https:\/\/taki-lab.site\/bocci\/?cat=225"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7823,"url":"https:\/\/taki-lab.site\/bocci\/?p=7823","url_meta":{"origin":6568,"position":3},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011MEMENTO\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2022\u5e742\u67089\u65e5","format":false,"excerpt":"\u51e6\u7406\u524d\u306e\u5185\u90e8\u72b6\u614b(Memento)\u3092\u4fdd\u6301\u3057\u3001\u72b6\u614b\u3092\u5fa9\u5143\u3059\u308b\u4ed5\u7d44\u307f\u3067\u3059\u3002 package com.ex\u2026","rel":"","context":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","block_context":{"text":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","link":"https:\/\/taki-lab.site\/bocci\/?cat=225"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4619,"url":"https:\/\/taki-lab.site\/bocci\/?p=4619","url_meta":{"origin":6568,"position":4},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Prototype\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2020\u5e7411\u670826\u65e5","format":false,"excerpt":"Prototype\u30d1\u30bf\u30fc\u30f3\u306e\u30b3\u30fc\u30c8\u4f8b\u3067\u3059\u3002 package org.example.prototyp\u2026","rel":"","context":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","block_context":{"text":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","link":"https:\/\/taki-lab.site\/bocci\/?cat=225"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5005,"url":"https:\/\/taki-lab.site\/bocci\/?p=5005","url_meta":{"origin":6568,"position":5},"title":"\u3010\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3\u3011Chain of Responsibility\u30d1\u30bf\u30fc\u30f3","author":"taki","date":"2021\u5e741\u670829\u65e5","format":false,"excerpt":"Chain of Responsibility\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\u3002 package org.exa\u2026","rel":"","context":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","block_context":{"text":"\u30c7\u30b6\u30a4\u30f3\u30d1\u30bf\u30fc\u30f3","link":"https:\/\/taki-lab.site\/bocci\/?cat=225"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/posts\/6568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6568"}],"version-history":[{"count":1,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/posts\/6568\/revisions"}],"predecessor-version":[{"id":6570,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=\/wp\/v2\/posts\/6568\/revisions\/6570"}],"wp:attachment":[{"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taki-lab.site\/bocci\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}