package cn.dragon.arithmetic.model; import java.util.LinkedList; //链表实现双端队列 public class MyListDeque<T> { private LinkedList<T> list = new LinkedList<>(); void addFirst(T d) { list.addFirst(d); } void addLast(T d) { list.addLast(d); } T removeFirst() { return list.removeFirst(); } T removeLast() { return list.removeLast(); } T peekFirst() { return list.getFirst(); } T peekLast() { return list.getLast(); } }