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

📄 emptymap.java

📁 BOOK:Beginning Algorithms Code Examples
💻 JAVA
字号:
package com.wrox.algorithms.maps;import com.wrox.algorithms.iteration.EmptyIterator;import com.wrox.algorithms.iteration.Iterator;/** * A {@link Map} that is always empty. * */public final class EmptyMap implements Map {    /** The single instance of the class. */    public static final EmptyMap INSTANCE = new EmptyMap();    /**     * Constructor marked private to prevent instantiation.     */    private EmptyMap() {    }    public Object get(Object key) {        return null;    }    public Object set(Object key, Object value) {        throw new UnsupportedOperationException();    }    public Object delete(Object key) {        throw new UnsupportedOperationException();    }    public boolean contains(Object key) {        return false;    }    public void clear() {    }    public int size() {        return 0;    }    public boolean isEmpty() {        return true;    }    public Iterator iterator() {        return EmptyIterator.INSTANCE;    }}

⌨️ 快捷键说明

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