| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_IN_MEMORY_URL_INDEX_TYPES_H_ | 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_IN_MEMORY_URL_INDEX_TYPES_H_ |
| 6 #define COMPONENTS_OMNIBOX_BROWSER_IN_MEMORY_URL_INDEX_TYPES_H_ | 6 #define COMPONENTS_OMNIBOX_BROWSER_IN_MEMORY_URL_INDEX_TYPES_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/containers/flat_map.h" |
| 15 #include "base/containers/flat_set.h" |
| 14 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
| 15 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 16 #include "components/history/core/browser/history_types.h" | 18 #include "components/history/core/browser/history_types.h" |
| 17 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 18 | 20 |
| 19 // Matches within URL and Title Strings ---------------------------------------- | 21 // Matches within URL and Title Strings ---------------------------------------- |
| 20 | 22 |
| 21 // Specifies where an omnibox term occurs within a string. Used for specifying | 23 // Specifies where an omnibox term occurs within a string. Used for specifying |
| 22 // highlights in AutocompleteMatches (ACMatchClassifications) and to assist in | 24 // highlights in AutocompleteMatches (ACMatchClassifications) and to assist in |
| 23 // scoring a result. | 25 // scoring a result. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // |offsets| gives beginning and ending offsets for each match; this function | 64 // |offsets| gives beginning and ending offsets for each match; this function |
| 63 // translates (beginning, ending) offset into (beginning offset, length of | 65 // translates (beginning, ending) offset into (beginning offset, length of |
| 64 // match). It deletes any matches for which an endpoint is npos and returns | 66 // match). It deletes any matches for which an endpoint is npos and returns |
| 65 // the updated list of matches. | 67 // the updated list of matches. |
| 66 TermMatches ReplaceOffsetsInTermMatches(const TermMatches& matches, | 68 TermMatches ReplaceOffsetsInTermMatches(const TermMatches& matches, |
| 67 const std::vector<size_t>& offsets); | 69 const std::vector<size_t>& offsets); |
| 68 | 70 |
| 69 // Convenience Types ----------------------------------------------------------- | 71 // Convenience Types ----------------------------------------------------------- |
| 70 | 72 |
| 71 typedef std::vector<base::string16> String16Vector; | 73 typedef std::vector<base::string16> String16Vector; |
| 72 typedef std::set<base::string16> String16Set; | 74 typedef base::flat_set<base::string16> String16Set; |
| 73 typedef std::set<base::char16> Char16Set; | 75 typedef base::flat_set<base::char16> Char16Set; |
| 74 typedef std::vector<base::char16> Char16Vector; | 76 typedef std::vector<base::char16> Char16Vector; |
| 75 | 77 |
| 76 // A vector that contains the offsets at which each word starts within a string. | 78 // A vector that contains the offsets at which each word starts within a string. |
| 77 typedef std::vector<size_t> WordStarts; | 79 typedef std::vector<size_t> WordStarts; |
| 78 | 80 |
| 79 // Utility Functions ----------------------------------------------------------- | 81 // Utility Functions ----------------------------------------------------------- |
| 80 | 82 |
| 81 // Breaks the string |cleaned_uni_string| down into individual words. | 83 // Breaks the string |cleaned_uni_string| down into individual words. |
| 82 // Use CleanUpUrlForMatching() or CleanUpUrlTitleMatching() before | 84 // Use CleanUpUrlForMatching() or CleanUpUrlTitleMatching() before |
| 83 // passing |cleaned_uni_string| to this function. If |word_starts| is | 85 // passing |cleaned_uni_string| to this function. If |word_starts| is |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 126 |
| 125 // Support for InMemoryURLIndex Private Data ----------------------------------- | 127 // Support for InMemoryURLIndex Private Data ----------------------------------- |
| 126 | 128 |
| 127 // An index into a list of all of the words we have indexed. | 129 // An index into a list of all of the words we have indexed. |
| 128 typedef size_t WordID; | 130 typedef size_t WordID; |
| 129 | 131 |
| 130 // A map allowing a WordID to be determined given a word. | 132 // A map allowing a WordID to be determined given a word. |
| 131 typedef std::map<base::string16, WordID> WordMap; | 133 typedef std::map<base::string16, WordID> WordMap; |
| 132 | 134 |
| 133 // A map from character to the word_ids of words containing that character. | 135 // A map from character to the word_ids of words containing that character. |
| 134 typedef std::set<WordID> WordIDSet; // An index into the WordList. | 136 typedef base::flat_set<WordID> WordIDSet; // An index into the WordList. |
| 135 typedef std::map<base::char16, WordIDSet> CharWordIDMap; | 137 typedef base::flat_map<base::char16, WordIDSet> CharWordIDMap; |
| 136 | 138 |
| 137 // A map from word (by word_id) to history items containing that word. | 139 // A map from word (by word_id) to history items containing that word. |
| 138 typedef history::URLID HistoryID; | 140 typedef history::URLID HistoryID; |
| 139 typedef std::set<HistoryID> HistoryIDSet; | 141 typedef base::flat_set<HistoryID> HistoryIDSet; |
| 140 typedef std::vector<HistoryID> HistoryIDVector; | 142 typedef std::vector<HistoryID> HistoryIDVector; |
| 141 typedef std::map<WordID, HistoryIDSet> WordIDHistoryMap; | 143 typedef base::flat_map<WordID, HistoryIDSet> WordIDHistoryMap; |
| 142 typedef std::map<HistoryID, WordIDSet> HistoryIDWordMap; | 144 typedef base::flat_map<HistoryID, WordIDSet> HistoryIDWordMap; |
| 143 | |
| 144 | 145 |
| 145 // Information used in scoring a particular URL. | 146 // Information used in scoring a particular URL. |
| 146 typedef std::vector<history::VisitInfo> VisitInfoVector; | 147 typedef std::vector<history::VisitInfo> VisitInfoVector; |
| 147 struct HistoryInfoMapValue { | 148 struct HistoryInfoMapValue { |
| 148 HistoryInfoMapValue(); | 149 HistoryInfoMapValue(); |
| 149 HistoryInfoMapValue(const HistoryInfoMapValue& other); | 150 HistoryInfoMapValue(const HistoryInfoMapValue& other); |
| 150 ~HistoryInfoMapValue(); | 151 ~HistoryInfoMapValue(); |
| 151 | 152 |
| 152 // This field is always populated. | 153 // This field is always populated. |
| 153 history::URLRow url_row; | 154 history::URLRow url_row; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 167 RowWordStarts(); | 168 RowWordStarts(); |
| 168 RowWordStarts(const RowWordStarts& other); | 169 RowWordStarts(const RowWordStarts& other); |
| 169 ~RowWordStarts(); | 170 ~RowWordStarts(); |
| 170 | 171 |
| 171 // Clears both url_word_starts_ and title_word_starts_. | 172 // Clears both url_word_starts_ and title_word_starts_. |
| 172 void Clear(); | 173 void Clear(); |
| 173 | 174 |
| 174 WordStarts url_word_starts_; | 175 WordStarts url_word_starts_; |
| 175 WordStarts title_word_starts_; | 176 WordStarts title_word_starts_; |
| 176 }; | 177 }; |
| 177 typedef std::map<HistoryID, RowWordStarts> WordStartsMap; | 178 typedef base::flat_map<HistoryID, RowWordStarts> WordStartsMap; |
| 178 | 179 |
| 179 #endif // COMPONENTS_OMNIBOX_BROWSER_IN_MEMORY_URL_INDEX_TYPES_H_ | 180 #endif // COMPONENTS_OMNIBOX_BROWSER_IN_MEMORY_URL_INDEX_TYPES_H_ |
| OLD | NEW |