//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Example 5.9 on page 101
//  A removeAll() method for the Bag class

  public boolean removeAll(Object object)
  { // removes all of the given object from this bag;
    // returns true iff this bag was modified;
    boolean modified=false;
    for (int i=0; i<size; i++)
      if (object.equals(objects[i]))
      { objects[i] = objects[--size];
        modified = true;
      }
    return modified;
  }
  