一、双端队列的定义
双端队列(double ended queue ,deque)
是限定插入和删除操作在表的两端进行的线性表
是一种具有队列和栈的性质的数据结构
总的来说就是在循环队列的基础上让其无论在头部还是尾部都可以进行增删
从而可以同时实现队列合栈的全部功能
二、Deque双端队列接口的定义
双端队列大致思想与循环队列一样
无非在队首可添加,在队尾可删除
public interface Dequeue<E> extends Queue<E> {
public void addFirst(E element);
public void addLast(E element);
public E removeFirst();
public E removeLast();
public E getFirst();
public E getLast();
}
三、基于新定义的接口实现的实现类——ArrayDeque类
四、代码
package p2.线性