title: Queue modulus in en-queue and de-queue method?
body: <p>So I have this code I need to analyze and learn from it, about how bounded queue works, here it is:</p>
  
  <pre><code>class Queue&lt;T&gt; { // bounded
  
      private T[] seq; // the sequence
      private int size = 0; // size of sequence
      private int head = 0; private int tail = 0; // front and rear
  
      Queue(int n) { // n&gt;0
          seq = (T[])(new Object[n]); 
      }
  
      Queue(){ this(10000);} // =  seq=(T[])(new Object[10000]);
  
      boolean isEmpty() { return size==0;}
  
      boolean enq(T t) { 
          if (size&lt;seq.length) {
                  seq[tail] = t; tail = (tail+1)%seq.length; size++; 
                  return true;
          }
          else return false;
      }
  
      T deq() {
          if (isEmpty()) return null;
          else {
              T temp = seq[head];
              head = (head+1)%seq.length; size--;
              return temp;
          }
      }
  }
  </code></pre>
  
  <p>So everything is okay, but I don't understand why in the name of god is there a modulus (<code>%</code>) operation in the <code>enq(T t)</code> method and <code>deq()</code> method...</p>