List<BugInstance> retained = new LinkedList<BugInstance>(); for (Iterator<BugInstance> i = origCollection.iterator(); i.hasNext();) { BugInstance origBugInstance = i.next(); if (result.contains(origBugInstance)) { retained.add(origBugInstance); } } result.clear(); result.addAll(retained);
List<BugInstance> inBoth = getSharedInstances(result, origCollection);   replaceBugInstances(result, inBoth);
		public SortedBugCollection perform(Set<BugInstance> result,				SortedBugCollection origCollection, SortedBugCollection newCollection) {			result.addAll(newCollection.getCollection());			if (DEBUG) System.out.println(result.size() + " instances initially");			//result.retainAll(origCollection.getCollection());			List<BugInstance> retained = new LinkedList<BugInstance>();			for (Iterator<BugInstance> i = origCollection.iterator(); i.hasNext();) {				BugInstance origBugInstance = i.next();				if (result.contains(origBugInstance)) {					retained.add(origBugInstance);				}			}			result.clear();			result.addAll(retained);			if (DEBUG) System.out.println(result.size() + " after retaining new instances");			return newCollection;		}