| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 typedef MappedTraitsArg MappedTraits; | 51 typedef MappedTraitsArg MappedTraits; |
| 52 typedef HashMapValueTraits<KeyTraits, MappedTraits> ValueTraits; | 52 typedef HashMapValueTraits<KeyTraits, MappedTraits> ValueTraits; |
| 53 | 53 |
| 54 public: | 54 public: |
| 55 typedef typename KeyTraits::TraitType KeyType; | 55 typedef typename KeyTraits::TraitType KeyType; |
| 56 typedef const typename KeyTraits::PeekInType& KeyPeekInType; | 56 typedef const typename KeyTraits::PeekInType& KeyPeekInType; |
| 57 typedef typename MappedTraits::TraitType MappedType; | 57 typedef typename MappedTraits::TraitType MappedType; |
| 58 typedef typename ValueTraits::TraitType ValueType; | 58 typedef typename ValueTraits::TraitType ValueType; |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 typedef typename MappedTraits::PassInType MappedPassInType; | |
| 62 typedef typename MappedTraits::PeekOutType MappedPeekType; | 61 typedef typename MappedTraits::PeekOutType MappedPeekType; |
| 63 | 62 |
| 64 typedef HashArg HashFunctions; | 63 typedef HashArg HashFunctions; |
| 65 | 64 |
| 66 typedef HashTable<KeyType, ValueType, KeyValuePairKeyExtractor, | 65 typedef HashTable<KeyType, ValueType, KeyValuePairKeyExtractor, |
| 67 HashFunctions, ValueTraits, KeyTraits, Allocator> HashTableType; | 66 HashFunctions, ValueTraits, KeyTraits, Allocator> HashTableType; |
| 68 | 67 |
| 69 class HashMapKeysProxy; | 68 class HashMapKeysProxy; |
| 70 class HashMapValuesProxy; | 69 class HashMapValuesProxy; |
| 71 | 70 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 template <typename HashTranslator, typename T> const_iterator find(const T&)
const; | 134 template <typename HashTranslator, typename T> const_iterator find(const T&)
const; |
| 136 template <typename HashTranslator, typename T> bool contains(const T&) const
; | 135 template <typename HashTranslator, typename T> bool contains(const T&) const
; |
| 137 | 136 |
| 138 // An alternate version of add() that finds the object by hashing and | 137 // An alternate version of add() that finds the object by hashing and |
| 139 // comparing with some other type, to avoid the cost of type conversion if | 138 // comparing with some other type, to avoid the cost of type conversion if |
| 140 // the object is already in the table. HashTranslator must have the | 139 // the object is already in the table. HashTranslator must have the |
| 141 // following function members: | 140 // following function members: |
| 142 // static unsigned hash(const T&); | 141 // static unsigned hash(const T&); |
| 143 // static bool equal(const ValueType&, const T&); | 142 // static bool equal(const ValueType&, const T&); |
| 144 // static translate(ValueType&, const T&, unsigned hashCode); | 143 // static translate(ValueType&, const T&, unsigned hashCode); |
| 145 template <typename HashTranslator, typename T> AddResult add(const T&, Mappe
dPassInType); | 144 template <typename HashTranslator, typename IncomingKeyType, typename Incomi
ngMappedType> |
| 145 AddResult add(IncomingKeyType&&, IncomingMappedType&&); |
| 146 | 146 |
| 147 static bool isValidKey(KeyPeekInType); | 147 static bool isValidKey(KeyPeekInType); |
| 148 | 148 |
| 149 template <typename VisitorDispatcher> | 149 template <typename VisitorDispatcher> |
| 150 void trace(VisitorDispatcher visitor) { m_impl.trace(visitor); } | 150 void trace(VisitorDispatcher visitor) { m_impl.trace(visitor); } |
| 151 | 151 |
| 152 private: | 152 private: |
| 153 template <typename IncomingKeyType, typename IncomingMappedType> | 153 template <typename IncomingKeyType, typename IncomingMappedType> |
| 154 AddResult inlineAdd(IncomingKeyType&&, IncomingMappedType&&); | 154 AddResult inlineAdd(IncomingKeyType&&, IncomingMappedType&&); |
| 155 | 155 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 // The inlineAdd call above found an existing hash table entry; we need | 370 // The inlineAdd call above found an existing hash table entry; we need |
| 371 // to set the mapped value. | 371 // to set the mapped value. |
| 372 // | 372 // |
| 373 // It's safe to call std::forward again, because |mapped| isn't moved if
there's an existing entry. | 373 // It's safe to call std::forward again, because |mapped| isn't moved if
there's an existing entry. |
| 374 MappedTraits::store(std::forward<IncomingMappedType>(mapped), result.sto
redValue->value); | 374 MappedTraits::store(std::forward<IncomingMappedType>(mapped), result.sto
redValue->value); |
| 375 } | 375 } |
| 376 return result; | 376 return result; |
| 377 } | 377 } |
| 378 | 378 |
| 379 template <typename T, typename U, typename V, typename W, typename X, typename Y
> | 379 template <typename T, typename U, typename V, typename W, typename X, typename Y
> |
| 380 template <typename HashTranslator, typename TYPE> | 380 template <typename HashTranslator, typename IncomingKeyType, typename IncomingMa
ppedType> |
| 381 typename HashMap<T, U, V, W, X, Y>::AddResult | 381 auto HashMap<T, U, V, W, X, Y>::add(IncomingKeyType&& key, IncomingMappedType&&
mapped) -> AddResult |
| 382 HashMap<T, U, V, W, X, Y>::add(const TYPE& key, MappedPassInType value) | |
| 383 { | 382 { |
| 384 return m_impl.template addPassingHashCode<HashMapTranslatorAdapter<ValueTrai
ts, HashTranslator>>(key, value); | 383 return m_impl.template addPassingHashCode<HashMapTranslatorAdapter<ValueTrai
ts, HashTranslator>>( |
| 384 std::forward<IncomingKeyType>(key), std::forward<IncomingMappedType>(map
ped)); |
| 385 } | 385 } |
| 386 | 386 |
| 387 template <typename T, typename U, typename V, typename W, typename X, typename Y
> | 387 template <typename T, typename U, typename V, typename W, typename X, typename Y
> |
| 388 template <typename IncomingKeyType, typename IncomingMappedType> | 388 template <typename IncomingKeyType, typename IncomingMappedType> |
| 389 typename HashMap<T, U, V, W, X, Y>::AddResult | 389 typename HashMap<T, U, V, W, X, Y>::AddResult |
| 390 HashMap<T, U, V, W, X, Y>::add(IncomingKeyType&& key, IncomingMappedType&& mappe
d) | 390 HashMap<T, U, V, W, X, Y>::add(IncomingKeyType&& key, IncomingMappedType&& mappe
d) |
| 391 { | 391 { |
| 392 return inlineAdd(std::forward<IncomingKeyType>(key), std::forward<IncomingMa
ppedType>(mapped)); | 392 return inlineAdd(std::forward<IncomingKeyType>(key), std::forward<IncomingMa
ppedType>(mapped)); |
| 393 } | 393 } |
| 394 | 394 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 iterator end = collection.end().values(); | 497 iterator end = collection.end().values(); |
| 498 for (unsigned i = 0; it != end; ++it, ++i) | 498 for (unsigned i = 0; it != end; ++it, ++i) |
| 499 vector[i] = *it; | 499 vector[i] = *it; |
| 500 } | 500 } |
| 501 | 501 |
| 502 } // namespace WTF | 502 } // namespace WTF |
| 503 | 503 |
| 504 using WTF::HashMap; | 504 using WTF::HashMap; |
| 505 | 505 |
| 506 #endif // WTF_HashMap_h | 506 #endif // WTF_HashMap_h |
| OLD | NEW |