OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BOOKMARKS_BROWSER_TITLED_URL_INDEX_H_ | 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_TITLED_URL_INDEX_H_ |
6 #define COMPONENTS_BOOKMARKS_BROWSER_TITLED_URL_INDEX_H_ | 6 #define COMPONENTS_BOOKMARKS_BROWSER_TITLED_URL_INDEX_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <set> | |
12 #include <string> | 11 #include <string> |
13 #include <vector> | 12 #include <vector> |
14 | 13 |
| 14 #include "base/containers/flat_set.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "components/query_parser/query_parser.h" | 17 #include "components/query_parser/query_parser.h" |
18 | 18 |
19 namespace bookmarks { | 19 namespace bookmarks { |
20 | 20 |
21 class TitledUrlNode; | 21 class TitledUrlNode; |
22 class TitledUrlNodeSorter; | 22 class TitledUrlNodeSorter; |
23 struct TitledUrlMatch; | 23 struct TitledUrlMatch; |
24 | 24 |
(...skipping 18 matching lines...) Expand all Loading... |
43 | 43 |
44 // Returns up to |max_count| of matches containing each term from the text | 44 // Returns up to |max_count| of matches containing each term from the text |
45 // |query| in either the title or the URL. | 45 // |query| in either the title or the URL. |
46 void GetResultsMatching(const base::string16& query, | 46 void GetResultsMatching(const base::string16& query, |
47 size_t max_count, | 47 size_t max_count, |
48 query_parser::MatchingAlgorithm matching_algorithm, | 48 query_parser::MatchingAlgorithm matching_algorithm, |
49 std::vector<TitledUrlMatch>* results); | 49 std::vector<TitledUrlMatch>* results); |
50 | 50 |
51 private: | 51 private: |
52 using TitledUrlNodes = std::vector<const TitledUrlNode*>; | 52 using TitledUrlNodes = std::vector<const TitledUrlNode*>; |
53 using TitledUrlNodeSet = std::set<const TitledUrlNode*>; | 53 using TitledUrlNodeSet = base::flat_set<const TitledUrlNode*>; |
54 using Index = std::map<base::string16, TitledUrlNodeSet>; | 54 using Index = std::map<base::string16, TitledUrlNodeSet>; |
55 | 55 |
56 // Constructs |sorted_nodes| by copying the matches in |matches| and sorting | 56 // Constructs |sorted_nodes| by copying the matches in |matches| and sorting |
57 // them. | 57 // them. |
58 void SortMatches(const TitledUrlNodeSet& matches, | 58 void SortMatches(const TitledUrlNodeSet& matches, |
59 TitledUrlNodes* sorted_nodes) const; | 59 TitledUrlNodes* sorted_nodes) const; |
60 | 60 |
61 // Add |node| to |results| if the node matches the query. | 61 // Add |node| to |results| if the node matches the query. |
62 void AddMatchToResults(const TitledUrlNode* node, | 62 void AddMatchToResults(const TitledUrlNode* node, |
63 query_parser::QueryParser* parser, | 63 query_parser::QueryParser* parser, |
(...skipping 21 matching lines...) Expand all Loading... |
85 Index index_; | 85 Index index_; |
86 | 86 |
87 std::unique_ptr<TitledUrlNodeSorter> sorter_; | 87 std::unique_ptr<TitledUrlNodeSorter> sorter_; |
88 | 88 |
89 DISALLOW_COPY_AND_ASSIGN(TitledUrlIndex); | 89 DISALLOW_COPY_AND_ASSIGN(TitledUrlIndex); |
90 }; | 90 }; |
91 | 91 |
92 } // namespace bookmarks | 92 } // namespace bookmarks |
93 | 93 |
94 #endif // COMPONENTS_BOOKMARKS_BROWSER_TITLED_URL_INDEX_H_ | 94 #endif // COMPONENTS_BOOKMARKS_BROWSER_TITLED_URL_INDEX_H_ |
OLD | NEW |