[JAVA] 9.JAVA涓殑Collection

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[JAVA] 9.JAVA涓殑Collection相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/ima' title='ima'>ima   item   瀹炵幇   alt   rto   dex   lang   col   

Iterable

杩欐牱灏卞彲浠ラ亶鍘嗕笖涓嶆毚闇插唴閮ㄦ垚鍛榠tems

Iterable闇€瑕佸疄鐜癐terator锛岃€孖terator闇€瑕佸疄鐜癶asNext鍜宯ext

import java.util.Iterator;

public class GenericList<T> implements Iterable<T> {
    private T[] items = (T[]) new Object[10];
    private int count;

    public void push(T item) {
        items[count++] = item;
    }

    public T get(int index) {
        return items[index];
    }

    @Override
    public Iterator<T> iterator() {
        return new ListItertor(this);
    }

    private class ListItertor implements Iterator<T> {
        private GenericList<T> list;
        private int index;

        public ListItertor(GenericList<T> list) {
            this.list = list;
        }

        @Override
        public boolean hasNext() {
            return index < list.count;
        }

        @Override
        public T next() {
            return list.items[index++];
        }
    }
}

Hash Table

杩欎釜涓嶅睘浜嶪terable鎺ュ彛鐨勫疄鐜扮被

鎶€鏈浘鐗? src=php涓殑foreach寰幆

Vue涓殑 el 鍜?mount 鎸傝浇

璇﹁ВPython涓殑鍚勭杞箟绗n

鍏充簬javascript涓殑dataset

ul涓殑li璁剧疆绛夊楂榗ss

鑾峰彇json涓殑灞炴€у€硷紝鐢熸垚鏂癹son