code: public Iterator<ElementType> iterator() {
          return new Iterator<ElementType>() {
              int idx = getIdx;
              int N = size;
  
              public boolean hasNext() {
                  return N > 0;
              }
  
              public ElementType next() {
                  ElementType x = (ElementType) elements[idx];
                  idx = (idx + 1) % elements.length;
                  N--;
                  return x;
              }
  
              public void remove() {
                  throw new UnsupportedOperationException("remove");
              }
          };
      }
docs: Returns an iterator intended usage in a foreach loop
  @return an iterator that iterates over all elements in the queue