01: package org.columba.core.search;
02:
03: import java.util.Hashtable;
04: import java.util.Iterator;
05: import java.util.List;
06:
07: import org.columba.core.search.api.ISearchResult;
08:
09: public class DistinctResultHelper {
10:
11: /**
12: * Remove duplicates by searching for duplicate location URIs
13: */
14: public static void removeDuplicated(List<ISearchResult> list) {
15: // temporary hashtable to check for duplicated
16: Hashtable<String, String> hashtable = new Hashtable<String, String>();
17:
18: Iterator<ISearchResult> it = list.iterator();
19: while (it.hasNext()) {
20: ISearchResult r = it.next();
21:
22: // if result is already in hashtable remove from result set
23: if (hashtable.containsKey(r.getLocation().toString()))
24: it.remove();
25: else
26: // memorize location URI
27: hashtable.put(r.getLocation().toString(), r
28: .getLocation().toString());
29: }
30: }
31: }
|