code: protected void _copy(int new_cap) {
          // copy elements from [low to high-1] into new indices in new array
          T[] new_buf=(T[])new Object[new_cap];
          int new_len=new_buf.length;
          int old_len=this.buffer.length;
  
          for(long i=low, num_iterations=0; i < high && num_iterations < old_len; i++, num_iterations++) {
              int old_index=index(i, old_len);
              if(this.buffer[old_index] != null) {
                  int new_index=index(i, new_len);
                  new_buf[new_index]=this.buffer[old_index];
              }
          }
          this.buffer=new_buf;
      }
docs: Copies elements from old into new array