标签:class -- color new span div 数组 IV override
一.代码部分
1.定义接口:
public interface Queue<E> { void enqueue(E e); E dequeue(); E getFront(); int getSize(); boolean isEmpty(); }
2.基于数组的实现
public class ArrayQueue<E> implements Queue<E> { private ArrayList<E> arrayList; public ArrayQueue(int capacity){ arrayList = new ArrayList<>(capacity); } public ArrayQueue(){ arrayList = new ArrayList<>(); } @Override public void enqueue(E e) { arrayList.addLast(e); } @Override public E dequeue() { return arrayList.removeFirst(); } @Override public E getFront() { return arrayList.get(0); } @Override public int getSize() { return arrayList.getSize(); } @Override public boolean isEmpty() { return arrayList.isEmpty(); } }
标签:class -- color new span div 数组 IV override
原文地址:https://www.cnblogs.com/inspred/p/queue.html