Circular Queue Code


    public void insert(int val) {
      int next = this.end + 1;
      if ( next > = this.queue.length )
         next = 0;               // wrap around
 //      if ( next == this.front )
 //         throw new QueueFullException();
      this.queue[end] = val;
      this.end = next; }

    public int remove () {
        int val = this.queue[front];
        this.front++;
        if ( this.front > = this.queue.length )
            this.front = 0;        // wrap around
        return val; }

Contents    Page-10    Prev    Next    Page+10    Index