All pastes #820486 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-12-17 16:10 UTC
rendered paste body
  /**
   * Intersect takes all elements from list b that appears in
   * list a and removes them from list a and returns the 
   * manipulated list a.
   * 
   * @param set The list of items you want to remove
   * @return the manipulated list
   * @require this.size() != 0
   * @require set.size() != 0
   */
  @Override
public Set<T> intersect(Set<T> set){
	  Set<T> isSet = this;
	for (int i=0; i< this.size(); i++){
		for (int j=0; j< set.size(); j++){
			if (this.get(i).equals(set.get(j))){
				isSet.remove(i);
				i--;
				}
		}
	}
	return this;
}