//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Example 5.4 on page 99
//  A Bag.resize() method

  private void resize(int capacity)
  { // increases the length of objects[] to the given capacity
    if (capacity <= this.capacity) return;
    Object[] temp = objects;
    objects = new Object[capacity];
    for (int i=0; i<size; i++)
      objects[i] = temp[i];
  }