OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv
ed. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 typedef FirstTraitsArg FirstTraits; | 183 typedef FirstTraitsArg FirstTraits; |
184 typedef SecondTraitsArg SecondTraits; | 184 typedef SecondTraitsArg SecondTraits; |
185 typedef std::pair<typename FirstTraits::TraitType, typename SecondTraits
::TraitType> TraitType; | 185 typedef std::pair<typename FirstTraits::TraitType, typename SecondTraits
::TraitType> TraitType; |
186 typedef std::pair<typename FirstTraits::EmptyValueType, typename SecondT
raits::EmptyValueType> EmptyValueType; | 186 typedef std::pair<typename FirstTraits::EmptyValueType, typename SecondT
raits::EmptyValueType> EmptyValueType; |
187 | 187 |
188 static const bool emptyValueIsZero = FirstTraits::emptyValueIsZero && Se
condTraits::emptyValueIsZero; | 188 static const bool emptyValueIsZero = FirstTraits::emptyValueIsZero && Se
condTraits::emptyValueIsZero; |
189 static EmptyValueType emptyValue() { return std::make_pair(FirstTraits::
emptyValue(), SecondTraits::emptyValue()); } | 189 static EmptyValueType emptyValue() { return std::make_pair(FirstTraits::
emptyValue(), SecondTraits::emptyValue()); } |
190 | 190 |
191 static const bool needsDestruction = FirstTraits::needsDestruction || Se
condTraits::needsDestruction; | 191 static const bool needsDestruction = FirstTraits::needsDestruction || Se
condTraits::needsDestruction; |
192 | 192 |
193 static const int minimumTableSize = FirstTraits::minimumTableSize; | 193 static const unsigned minimumTableSize = FirstTraits::minimumTableSize; |
194 | 194 |
195 static void constructDeletedValue(TraitType& slot) { FirstTraits::constr
uctDeletedValue(slot.first); } | 195 static void constructDeletedValue(TraitType& slot) { FirstTraits::constr
uctDeletedValue(slot.first); } |
196 static bool isDeletedValue(const TraitType& value) { return FirstTraits:
:isDeletedValue(value.first); } | 196 static bool isDeletedValue(const TraitType& value) { return FirstTraits:
:isDeletedValue(value.first); } |
197 }; | 197 }; |
198 | 198 |
199 template<typename First, typename Second> | 199 template<typename First, typename Second> |
200 struct HashTraits<std::pair<First, Second> > : public PairHashTraits<HashTra
its<First>, HashTraits<Second> > { }; | 200 struct HashTraits<std::pair<First, Second> > : public PairHashTraits<HashTra
its<First>, HashTraits<Second> > { }; |
201 | 201 |
202 template<typename KeyTypeArg, typename ValueTypeArg> | 202 template<typename KeyTypeArg, typename ValueTypeArg> |
203 struct KeyValuePair { | 203 struct KeyValuePair { |
(...skipping 25 matching lines...) Expand all Loading... |
229 typedef KeyTraitsArg KeyTraits; | 229 typedef KeyTraitsArg KeyTraits; |
230 typedef ValueTraitsArg ValueTraits; | 230 typedef ValueTraitsArg ValueTraits; |
231 typedef KeyValuePair<typename KeyTraits::TraitType, typename ValueTraits
::TraitType> TraitType; | 231 typedef KeyValuePair<typename KeyTraits::TraitType, typename ValueTraits
::TraitType> TraitType; |
232 typedef KeyValuePair<typename KeyTraits::EmptyValueType, typename ValueT
raits::EmptyValueType> EmptyValueType; | 232 typedef KeyValuePair<typename KeyTraits::EmptyValueType, typename ValueT
raits::EmptyValueType> EmptyValueType; |
233 | 233 |
234 static const bool emptyValueIsZero = KeyTraits::emptyValueIsZero && Valu
eTraits::emptyValueIsZero; | 234 static const bool emptyValueIsZero = KeyTraits::emptyValueIsZero && Valu
eTraits::emptyValueIsZero; |
235 static EmptyValueType emptyValue() { return KeyValuePair<typename KeyTra
its::EmptyValueType, typename ValueTraits::EmptyValueType>(KeyTraits::emptyValue
(), ValueTraits::emptyValue()); } | 235 static EmptyValueType emptyValue() { return KeyValuePair<typename KeyTra
its::EmptyValueType, typename ValueTraits::EmptyValueType>(KeyTraits::emptyValue
(), ValueTraits::emptyValue()); } |
236 | 236 |
237 static const bool needsDestruction = KeyTraits::needsDestruction || Valu
eTraits::needsDestruction; | 237 static const bool needsDestruction = KeyTraits::needsDestruction || Valu
eTraits::needsDestruction; |
238 | 238 |
239 static const int minimumTableSize = KeyTraits::minimumTableSize; | 239 static const unsigned minimumTableSize = KeyTraits::minimumTableSize; |
240 | 240 |
241 static void constructDeletedValue(TraitType& slot) { KeyTraits::construc
tDeletedValue(slot.key); } | 241 static void constructDeletedValue(TraitType& slot) { KeyTraits::construc
tDeletedValue(slot.key); } |
242 static bool isDeletedValue(const TraitType& value) { return KeyTraits::i
sDeletedValue(value.key); } | 242 static bool isDeletedValue(const TraitType& value) { return KeyTraits::i
sDeletedValue(value.key); } |
243 }; | 243 }; |
244 | 244 |
245 template<typename Key, typename Value> | 245 template<typename Key, typename Value> |
246 struct HashTraits<KeyValuePair<Key, Value> > : public KeyValuePairHashTraits
<HashTraits<Key>, HashTraits<Value> > { }; | 246 struct HashTraits<KeyValuePair<Key, Value> > : public KeyValuePairHashTraits
<HashTraits<Key>, HashTraits<Value> > { }; |
247 | 247 |
248 template<typename T> | 248 template<typename T> |
249 struct NullableHashTraits : public HashTraits<T> { | 249 struct NullableHashTraits : public HashTraits<T> { |
250 static const bool emptyValueIsZero = false; | 250 static const bool emptyValueIsZero = false; |
251 static T emptyValue() { return reinterpret_cast<T>(1); } | 251 static T emptyValue() { return reinterpret_cast<T>(1); } |
252 }; | 252 }; |
253 | 253 |
254 } // namespace WTF | 254 } // namespace WTF |
255 | 255 |
256 using WTF::HashTraits; | 256 using WTF::HashTraits; |
257 using WTF::PairHashTraits; | 257 using WTF::PairHashTraits; |
258 using WTF::NullableHashTraits; | 258 using WTF::NullableHashTraits; |
259 using WTF::SimpleClassHashTraits; | 259 using WTF::SimpleClassHashTraits; |
260 | 260 |
261 #endif // WTF_HashTraits_h | 261 #endif // WTF_HashTraits_h |
OLD | NEW |