private <T>T[] copyElements(T[] a){
  if (head < tail) {
    System.arraycopy(elements,head,a,0,size());
  }
 else   if (head > tail) {
    int headPortionLen=elements.length - head;
    System.arraycopy(elements,head,a,0,headPortionLen);
    System.arraycopy(elements,0,a,headPortionLen,tail);
  }
  return a;
}

private < T > T [ ] copyElements ( T [ ] a ) { if ( head < tail ) { System . arraycopy ( elements , head , a , 0 , size ( ) ) ; } else if ( head > tail ) { int headPortionLen = elements . length - head ; System . arraycopy ( elements , head , a , 0 , headPortionLen ) ; System . arraycopy ( elements , 0 , a , headPortionLen , tail ) ; } return a ; }
copies the elements from our element array into the specified array , in order ( from first to last element in the deque ) . it is assumed that the array is large enough to hold all elements in the deque .
