@@ -0,0 +1,1699 @@
+package framework.utils;%0A%0A/**%0A * Utility class representing a ring buffer.%0A */%0Apublic class RingBuffer %7B%0A    /**%0A     * Create an empty RingBuffer object of the specified capacity.%0A     * @param  c the capacity%0A     */%0A    public RingBuffer(int c) %7B%0A        capacity    = c;%0A        size        = 0;%0A        first       = 0;%0A        last        = 0;%0A        buffer      = new Double%5Bcapacity%5D;%0A    %7D%0A%0A    /**%0A     * Get the current number of items stored in the buffer.%0A     * @return the number of items%0A     */%0A    public int size() %7B%0A        return size;%0A    %7D%0A%0A    /**%0A     * Test if the buffer is empty.%0A     * @return true if is empty, false otherwise%0A     */%0A    public boolean isEmpty() %7B%0A        return size == 0;%0A    %7D%0A%0A    /**%0A     * Test if the buffer is full.%0A     * @return true if it is full, false otherwise%0A     */%0A    public boolean isFull() %7B%0A        return size == capacity;%0A    %7D%0A%0A    /**%0A     * Add item at the end of the list.%0A     * @param x the item to be added%0A     */%0A    public void enqueue(Double x) %7B%0A        buffer%5Blast%5D    = x;%0A        last            = (last + 1) %25 capacity;%0A        size++;%0A    %7D%0A%0A    /**%0A     * Delete and return the item at the front of the list.%0A     * @return the deleted item%0A     */%0A    public Double dequeue() %7B%0A        Double item = buffer%5Bfirst%5D;%0A        first       = (first + 1) %25 capacity;%0A        size--;%0A        return item;%0A    %7D%0A%0A    /**%0A     * Return but do not delete the item at the front of the list.%0A     * @return the item at the front%0A     */%0A    public Double peek() %7B%0A        return buffer%5Bfirst%5D;%0A    %7D%0A%0A    Double%5B%5D    buffer;%0A    int         capacity;%0A    int         first;%0A    int         last;%0A    int         size;%0A%7D

Create a RingBuffer class to be used in the GuitarGenerator.