Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Derived from google3/util/gtl/stl_util.h | 5 // Derived from google3/util/gtl/stl_util.h |
| 6 | 6 |
| 7 #ifndef BASE_STL_UTIL_H_ | 7 #ifndef BASE_STL_UTIL_H_ |
| 8 #define BASE_STL_UTIL_H_ | 8 #define BASE_STL_UTIL_H_ |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 // Returns true if the sorted container |a1| contains all elements of the sorted | 250 // Returns true if the sorted container |a1| contains all elements of the sorted |
| 251 // container |a2|. | 251 // container |a2|. |
| 252 template <typename Arg1, typename Arg2> | 252 template <typename Arg1, typename Arg2> |
| 253 bool STLIncludes(const Arg1& a1, const Arg2& a2) { | 253 bool STLIncludes(const Arg1& a1, const Arg2& a2) { |
| 254 DCHECK(STLIsSorted(a1)); | 254 DCHECK(STLIsSorted(a1)); |
| 255 DCHECK(STLIsSorted(a2)); | 255 DCHECK(STLIsSorted(a2)); |
| 256 return std::includes(a1.begin(), a1.end(), | 256 return std::includes(a1.begin(), a1.end(), |
| 257 a2.begin(), a2.end()); | 257 a2.begin(), a2.end()); |
| 258 } | 258 } |
| 259 | 259 |
| 260 // Moves out and removes the top element of a std::priority_queue. | |
| 261 template <typename PriorityQueue> | |
|
Nico
2016/04/22 15:32:16
this is only called from two places. the loop is i
tzik
2016/04/25 11:36:26
Hmm, there are several user of the pattern. And I
| |
| 262 typename PriorityQueue::value_type | |
| 263 PopOutFromPriorityQueue(PriorityQueue* queue) { | |
| 264 using ValueType = typename PriorityQueue::value_type; | |
| 265 ValueType ret = std::move(const_cast<ValueType&>(queue->top())); | |
| 266 queue->pop(); | |
| 267 return ret; | |
| 268 } | |
| 269 | |
| 260 } // namespace base | 270 } // namespace base |
| 261 | 271 |
| 262 #endif // BASE_STL_UTIL_H_ | 272 #endif // BASE_STL_UTIL_H_ |
| OLD | NEW |