集合基於數組的實現:BagADT.java – JAVA編程語言程序開發技術文章

/**
* @Author 陳偉兵
* @Msn:cwbnig1982@hotmail.com
* @E-mail:chenweibing1982@sohu.com
* @CreateTime 2004-11-30
* @Version:1.0
*/
package com.cwbnig.util;

import java.util.Iterator;

public interface BagADT
{
//Adds one element to this bag
public void add(Object element);

//Remove and returns a random element from the bag
public Object removeRandom()throws EmptyBagException;

//Removes and returns the specified element from this bag
public Object remove(Object element)throws EmptyBagException,NoSuchElementException;

//Returns the union of this bag and the parameter
public BagADT union(BagADT set);

//Returns true if this bag contains the parameter
public boolean contains(Object target);

//Returns true if this bag and the parameter contain exacitly the same elements
public boolean isEmpty();

//Returns the number of elements in this set
public int size();

//Returns an iterator for the elements in this bag
public Iterator iterator();

//Returns a string representation of this bag
public String toString();
}

發佈留言