private void doubleCapacity(){
  int p=head;
  int n=elements.length;
  int r=n - p;
  int newCapacity=n << 1;
  if (newCapacity < 0)   throw new IllegalStateException("Sorry, deque too big");
  Object[] a=new Object[newCapacity];
  System.arraycopy(elements,p,a,0,r);
  System.arraycopy(elements,0,a,r,p);
  elements=a;
  head=0;
  tail=n;
}

private void doubleCapacity ( ) { int p = head ; int n = elements . length ; int r = n - p ; int newCapacity = n << 1 ; if ( newCapacity < 0 ) throw new IllegalStateException ( "Sorry, deque too big" ) ; Object [ ] a = new Object [ newCapacity ] ; System . arraycopy ( elements , p , a , 0 , r ) ; System . arraycopy ( elements , 0 , a , r , p ) ; elements = a ; head = 0 ; tail = n ; }
double the capacity of this deque . call only when full , i . e . , when head and tail have wrapped around to become equal .
