[freenet-cvs] r11287 - trunk/plugins/Librarian

toad at freenetproject.org toad at freenetproject.org
Thu Dec 7 19:40:31 UTC 2006


Author: toad
Date: 2006-12-07 19:40:31 +0000 (Thu, 07 Dec 2006)
New Revision: 11287

Modified:
   trunk/plugins/Librarian/Librarian.java
Log:
Librarian: Return results in order.

Modified: trunk/plugins/Librarian/Librarian.java
===================================================================
--- trunk/plugins/Librarian/Librarian.java	2006-12-07 19:27:53 UTC (rev 11286)
+++ trunk/plugins/Librarian/Librarian.java	2006-12-07 19:40:31 UTC (rev 11287)
@@ -120,10 +120,16 @@
 			if (!index[i].startsWith("?"))
 				break;
 			String parts[] = index[i].split(" ");
-			HashSet keyuris = new HashSet();
+			Vector keyuris = new Vector();
 			//System.err.println(":::" +  + ":::");
 			for (int j = 1 ; j < parts.length ; j++) {
-				keyuris.add(uris.get(Integer.parseInt(parts[j])));
+				int uriNumber = Integer.parseInt(parts[j]);
+				URIWrapper uw = (URIWrapper) uris.get(uriNumber);
+				// Yes I know this is O(n), but there shouldn't be that many hits for a single word.
+				// FIXME If there are, use a LinkedHashSet (note that this will cost far more memory).
+				// Don't use a plain HashSet, because we want the results returned IN ORDER.
+				if(!keyuris.contains(uw))
+					keyuris.add(uw);
 				//System.err.println();
 			}
 			




More information about the cvs mailing list