来自http://www.brpreiss.com/books/opus5/
的设计模式
public interface Comparable {
boolean isLT (Comparable object);
boolean isLE (Comparable object);
boolean isGT (Comparable object);
boolean isGE (Comparable object);
boolean isEQ (Comparable object);
boolean isNE (Comparable object);
int compare (Comparable object);
}
public interface Container extends Comparable{
int getCount();
boolean isEmpty();
boolean isFull();
void purge();
Enumeration getEnumeration();
}
public interface Queue extends Container {
Object getHead() throws ContainerEmptyException;
void enqueue (Object object) throws ContainerFullException;
Object dequeue() throws ContainerEmptyException;
}
除了number of elements
之外,我们可以用什么其他合理的标准来比较堆栈和队列。