@@ -0,0 +1,1860 @@
+/**%0A * Company%0A * Copyright (C) 2014-2017 All Rights Reserved.%0A */%0Apackage com.cwenao.datastructure;%0A%0Aimport java.util.NoSuchElementException;%0A%0A/**%0A * @author cwenao%0A * @version $Id QueueWithFixedSizeArray.java, v 0.1 2017-07-12 8:06 cwenao Exp $$%0A */%0Apublic class QueueWithFixedSizeArray%3CE%3E %7B%0A%0A    private E%5B%5D queue = null;%0A    private int maxSize = 30;%0A    private int currentIndex;%0A%0A    public QueueWithFixedSizeArray() %7B%0A        queue = (E%5B%5D) new Object%5B30%5D;%0A        currentIndex = 0;%0A    %7D%0A%0A    public QueueWithFixedSizeArray(int capacity) %7B%0A        queue = (E%5B%5D) new Object%5Bcapacity%5D;%0A        currentIndex = 0;%0A        maxSize = capacity;%0A    %7D%0A%0A    public E enqueue(E value) %7B%0A        if (currentIndex %3E= maxSize) %7B%0A            throw new NoSuchElementException(%22 The queue is full%22);%0A        %7D%0A        queue%5BcurrentIndex%5D = value;%0A        if (currentIndex %3C maxSize-1) %7B%0A            currentIndex++;%0A        %7D%0A        return value;%0A    %7D%0A%0A    public E dequeue() %7B%0A        if (currentIndex == 0) %7B%0A            throw new NoSuchElementException(%22 The queue is empty%22);%0A        %7D%0A%0A        E tmp = queue%5B0%5D;%0A        for(int i = 0; i%3CcurrentIndex; i++) %7B%0A            queue%5Bi%5D = queue%5Bi + 1%5D;%0A        %7D%0A        if (currentIndex %3C maxSize -1)%0A            queue%5BcurrentIndex%5D = queue%5BcurrentIndex + 1%5D;%0A%0A        currentIndex--;%0A%0A        return tmp;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        QueueWithFixedSizeArray%3CInteger%3E queueWithFixedSizeArray = new QueueWithFixedSizeArray(5);%0A        queueWithFixedSizeArray.enqueue(5);%0A        queueWithFixedSizeArray.enqueue(10);%0A        queueWithFixedSizeArray.enqueue(50);%0A        queueWithFixedSizeArray.enqueue(100);%0A        queueWithFixedSizeArray.enqueue(25);%0A%0A        System.out.println(queueWithFixedSizeArray.dequeue());%0A        System.out.println(queueWithFixedSizeArray.dequeue());%0A%0A    %7D%0A%0A%7D%0A%0A

update the queue