emptyiterator.java
来自「BOOK:Beginning Algorithms Code Example」· Java 代码 · 共 43 行
JAVA
43 行
package com.wrox.algorithms.iteration;/** * An {@link Iterator} where {@link #isDone()} always returns <code>true</code>. * */public final class EmptyIterator implements Iterator { /** The single, publicly accessible, instance of the comparator. */ public static final EmptyIterator INSTANCE = new EmptyIterator(); /** * Constructor marked private to prevent instantiation. */ private EmptyIterator() { // Nothing to do } public void first() { // Nothing to do } public void last() { // Nothing to do } public boolean isDone() { // We're always done! return true; } public void next() { // Nothing to do } public void previous() { // Nothing to do } public Object current() throws IteratorOutOfBoundsException { throw new IteratorOutOfBoundsException(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?