⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapkeyiterator.java

📁 BOOK:Beginning Algorithms Code Examples
💻 JAVA
字号:
package com.wrox.algorithms.maps;import com.wrox.algorithms.iteration.Iterator;import com.wrox.algorithms.iteration.IteratorOutOfBoundsException;/** * An iterator over all the keys in a {@link Map}. * */public class MapKeyIterator implements Iterator {    /** The underlying iterator over the map entries. */    private final Iterator _entries;    /**     * Constructor.     *     * @param entries The underlying iterator over the map entries.     */    public MapKeyIterator(Iterator entries) {        assert entries != null : "entries can't be null";        _entries = entries;    }    public void first() {        _entries.first();    }    public void last() {        _entries.last();    }    public boolean isDone() {        return _entries.isDone();    }    public void next() {        _entries.next();    }    public void previous() {        _entries.previous();    }    public Object current() throws IteratorOutOfBoundsException {        return ((Map.Entry) _entries.current()).getKey();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -