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 TOOLS_GN_UNIQUE_VECTOR_H_ | 5 #ifndef TOOLS_GN_UNIQUE_VECTOR_H_ |
6 #define TOOLS_GN_UNIQUE_VECTOR_H_ | 6 #define TOOLS_GN_UNIQUE_VECTOR_H_ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 class UniquifyRef { | 26 class UniquifyRef { |
27 public: | 27 public: |
28 UniquifyRef() | 28 UniquifyRef() |
29 : value_(nullptr), | 29 : value_(nullptr), |
30 vect_(nullptr), | 30 vect_(nullptr), |
31 index_(static_cast<size_t>(-1)), | 31 index_(static_cast<size_t>(-1)), |
32 hash_val_(0) { | 32 hash_val_(0) { |
33 } | 33 } |
34 | 34 |
35 // Initialize with a pointer to a value. | 35 // Initialize with a pointer to a value. |
36 UniquifyRef(const T* v) | 36 explicit UniquifyRef(const T* v) |
37 : value_(v), | 37 : value_(v), |
38 vect_(nullptr), | 38 vect_(nullptr), |
39 index_(static_cast<size_t>(-1)) { | 39 index_(static_cast<size_t>(-1)) { |
40 FillHashValue(); | 40 FillHashValue(); |
41 } | 41 } |
42 | 42 |
43 // Initialize with an array + index. | 43 // Initialize with an array + index. |
44 UniquifyRef(const std::vector<T>* v, size_t i) | 44 UniquifyRef(const std::vector<T>* v, size_t i) |
45 : value_(nullptr), | 45 : value_(nullptr), |
46 vect_(v), | 46 vect_(v), |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 167 |
168 private: | 168 private: |
169 typedef internal::UniquifyRef<T> Ref; | 169 typedef internal::UniquifyRef<T> Ref; |
170 typedef base::hash_set<Ref> HashSet; | 170 typedef base::hash_set<Ref> HashSet; |
171 | 171 |
172 HashSet set_; | 172 HashSet set_; |
173 Vector vector_; | 173 Vector vector_; |
174 }; | 174 }; |
175 | 175 |
176 #endif // TOOLS_GN_UNIQUE_VECTOR_H_ | 176 #endif // TOOLS_GN_UNIQUE_VECTOR_H_ |
OLD | NEW |