private List<AutocompleteResultsModel> collateResultsForAutoCompleteResponse(
            ConcurrentMap<String, List<Tuple<SearchResult, String>>> resultsMap,
            int maxTextLength) {
        SortedMap<Integer, List<AutocompleteResultsModel>> prioritizedResultsMap =
                getCleanedAndSortedMapResults(resultsMap, maxTextLength);

        // Consolidate the results into a single, ordered list of max entries.
        List<AutocompleteResultsModel> results = new ArrayList<>();
        for (List<AutocompleteResultsModel> items : prioritizedResultsMap.values()) {
            results.addAll(items);
            if (results.size() >= maxAutocompleteSearchResults) {
                break;
            }
        }
        return results.subList(
                0,
                results.size() > maxAutocompleteSearchResults
                        ? maxAutocompleteSearchResults
                        : results.size());
    }
private List < AutocompleteResultsModel > collateResultsForAutoCompleteResponse ( ConcurrentMap < String , List < Tuple < SearchResult , String > > > resultsMap , int maxTextLength ) { SortedMap < Integer , List < AutocompleteResultsModel > > prioritizedResultsMap = getCleanedAndSortedMapResults ( resultsMap , maxTextLength ) ; List < AutocompleteResultsModel > results = new ArrayList < > ( ) ; for ( List < AutocompleteResultsModel > items : prioritizedResultsMap . values ( ) ) { results . addAll ( items ) ; if ( results . size ( ) >= maxAutocompleteSearchResults ) { break ; } } return results . subList ( 0 , results . size ( ) > maxAutocompleteSearchResults ? maxAutocompleteSearchResults : results . size ( ) ) ; }
Accepts a map (tab name, List of tuple search results) and returns a prioritized list of
results for the ajax autocomplete feature. The computing impact of moving the list items
around should be fairly small since there are not too many search results (unless we get a
lot of search providers, in which case the results could be put into the appropriate format
in the Event SEARCH_RESULTS_QNAME_STRING handling).

<p>Note that the method (as well as the SearchResults Event handler) do not impose a
consistent ordering on results. The results are ordered by priority, but within a particular
priority the same search may have results ordered differently based upon when the
SearchResults Event handler receives the search results event list. Also if a search result
is in multiple category types, even within the same priority, the search result will show up
multiple times. Currently all results are in a single category so it is not worth adding
extra complexity to handle a situation that is not present.

<p>This method also cleans up and trims down the amount of data shipped so the feature is
more responsive, especially on mobile networks.

@param resultsMap
@return