# 队列分类
package java.util; | |
public interface Queue<E> extends Collection<E> { | |
//true - 入队成功;异常 IllegalStateException - 容量不足 | |
// ClassCastException、NullPointerException、IllegalArgumentException | |
boolean add(E e); | |
//true - 入队成功;false - 容量不足 | |
// ClassCastException、NullPointerException、IllegalArgumentException | |
boolean offer(E e); | |
// E - 队头元素出队;异常 NoSuchElementException - 队列为空 | |
E remove(); | |
// E - 队头元素出队;null - 队列为空 | |
E poll(); | |
// E - 查看队头元素;异常 NoSuchElementException - 队列为空 | |
E element(); | |
// E - 查看队头元素;null - 队列为空 | |
E peek(); | |
} |
package java.util; | |
// Xxx => First 或 Last | |
public interface Deque<E> extends Queue<E> { | |
boolean addXxx(E e); | |
boolean offerXxx(E e); | |
E removeXxx(); | |
E pollXxx(); | |
//get 对应 Queue 的 element | |
E getXxx(); | |
E peekXxx(); | |
//------- 新增 ------- | |
// 在 Queue 基础上新增的 | |
// 移除 [第一次 / 最后] 出现 的元素。 | |
// ClassCastException、NullPointerException | |
//false - 元素不存在;true - 移除成功 | |
boolean removeXxxOccurrence(Object o); | |
} |