for(int i=0; i<vec.length; i++) vec[i] = null;
}
- /** Add an element to the queue */
+ /** Add an element to the front of the queue */
+ public synchronized void prepend(Object o) {
+ if (size == vec.length) grow(vec.length * 2);
+ first--;
+ if (first < 0) first += vec.length;
+ vec[first] = o;
+ size++;
+ if (size == 1) notify();
+ }
+
+ /** Add an element to the back of the queue */
public synchronized void append(Object o) {
if (size == vec.length) grow(vec.length * 2);
if (first + size >= vec.length) vec[first + size - vec.length] = o;