set.java

来自「BOOK:Beginning Algorithms Code Example」· Java 代码 · 共 53 行

JAVA
53
字号
package com.wrox.algorithms.sets;import com.wrox.algorithms.iteration.Iterable;/** * Generic interface for sets. * */public interface Set extends Iterable {    /**     * Determines if a value exists in the set.     *     * @param value The value for which to search.     * @return <code>true</code> if found; otherwise <code>false</code>.     */    public boolean contains(Object value);    /**     * Adds a value to the set.     *     * @param value The value to add.     * @return <code>true</code> if added; otherwise <code>false</code> if already existed.     */    public boolean add(Object value);    /**     * Removes a value from the set.     *     * @param value The value to delete.     * @return <code>true</code> if removed; otherwise <code>false</code> if not found.     */    public boolean delete(Object value);    /**     * Deletes all values from the set. The size of the set will be reset to zero (0).     */    public void clear();    /**     * Obtains the size of the set.     *     * @return The number of values in the set.     */    public int size();    /**     * Determines if the set is empty or not.     *     * @return <code>true</code> if the set is empty (<code>size() == 0</code>); otherwise returns <code>false</code>.     */    public boolean isEmpty();}

⌨️ 快捷键说明

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