/** * Returns an array of the current elements in the queue. The order of * elements is in reverse order of the order items were added. * * @param type * @return An array containing the current elements in the queue. The first * element of the array is the tail of the queue and the last * element is the head of the queue */ public T[] toArray(T[] type) { System.getProperties(); if (type.length > maxSize) { throw new IllegalArgumentException("Size of array passed in cannot be greater than " + maxSize); } int curIndex = getCurrentIndex(); for (int k = 0; k < type.length; k++) { int index = getIndex(curIndex - k); type[k] = circularArray[index].get(); } return type; }
/** * Returns an array of the current elements in the queue. The order of * elements is in reverse order of the order items were added. * * @param type * @return An array containing the current elements in the queue. The first * element of the array is the tail of the queue and the last * element is the head of the queue */ public T[] toArray(T[] type) { System.getProperties(); if (type.length > maxSize) { throw new IllegalArgumentException("Size of array passed in cannot be greater than " + maxSize); } int curIndex = getCurrentIndex(); for (int k = 0; k < type.length; k++) { int index = getIndex(curIndex - k); type[k] = circularArray[index].get(); } return type; }
/** * Returns value at the tail of the queue * * @return Value at the tail of the queue */ public T peek() { if (depth() == 0) { return null; } return circularArray[getIndex(getCurrentIndex())].get(); }
/** * Returns value at the tail of the queue * * @return Value at the tail of the queue */ public T peek() { if (depth() == 0) { return null; } return circularArray[getIndex(getCurrentIndex())].get(); }