Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Performs a partial search on a query
- *
- * @param queries
- * @return ArrayList of QueryResult objects
- */
- private List<QueryResult> partialSearch(Collection<String> queries) {
- // Temporary Map to combine results
- HashMap<String, QueryResult> combinedResults = new HashMap<>();
- ArrayList<QueryResult> queryResults = new ArrayList<>();
- // Get and combine the results
- for(String query : queries) {
- for(String key : index.tailMap(query).keySet()) {
- if(key.startsWith(query)) {
- for(String location : this.index.get(key).keySet()) {
- if(combinedResults.containsKey(location)) {
- combinedResults.get(location)
- .updateMatchCount(key, location);
- }
- else {
- QueryResult result = new QueryResult(location);
- result.updateMatchCount(key, location);
- combinedResults.put(location, result);
- queryResults.add(result);
- }
- }
- }
- }
- }
- Collections.sort(queryResults);
- return queryResults;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement