OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 static std::set<E> Convert(const Array<T>& input) { | 288 static std::set<E> Convert(const Array<T>& input) { |
289 std::set<E> result; | 289 std::set<E> result; |
290 if (!input.is_null()) { | 290 if (!input.is_null()) { |
291 for (size_t i = 0; i < input.size(); ++i) | 291 for (size_t i = 0; i < input.size(); ++i) |
292 result.insert(TypeConverter<E, T>::Convert(input[i])); | 292 result.insert(TypeConverter<E, T>::Convert(input[i])); |
293 } | 293 } |
294 return result; | 294 return result; |
295 } | 295 } |
296 }; | 296 }; |
297 | 297 |
| 298 // Less than operator to allow Arrays as keys in std maps and sets. |
| 299 template <typename T> |
| 300 inline bool operator<(const Array<T>& a, const Array<T>& b) { |
| 301 if (a.is_null()) |
| 302 return !b.is_null(); |
| 303 if (b.is_null()) |
| 304 return false; |
| 305 return a.storage() < b.storage(); |
| 306 } |
| 307 |
298 } // namespace mojo | 308 } // namespace mojo |
299 | 309 |
300 #endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ | 310 #endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ |
OLD | NEW |