读书人

器皿学习五:TreeMap源码分析

发布时间: 2012-12-23 11:28:15 作者: rapoo

容器学习五:TreeMap源码分析

一.TreeMap成员变量

/**     * Base class for TreeMap Iterators     */    abstract class PrivateEntryIterator<T> implements Iterator<T> {        Entry<K,V> next;        Entry<K,V> lastReturned;        int expectedModCount;        PrivateEntryIterator(Entry<K,V> first) {            expectedModCount = modCount;            lastReturned = null;            next = first;        }        //后继迭代final Entry<K,V> nextEntry() {            Entry<K,V> e = next;            if (e == null)                throw new NoSuchElementException();            if (modCount != expectedModCount)                throw new ConcurrentModificationException();            next = successor(e);            lastReturned = e;            return e;        }        //前驱迭代        final Entry<K,V> prevEntry() {            Entry<K,V> e = next;            if (e == null)                throw new NoSuchElementException();            if (modCount != expectedModCount)                throw new ConcurrentModificationException();            next = predecessor(e);            lastReturned = e;            return e;        }    }

读书人网 >编程

热点推荐