| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 * | 18 * |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #ifndef WTF_HashMap_h | 21 #ifndef WTF_HashMap_h |
| 22 #define WTF_HashMap_h | 22 #define WTF_HashMap_h |
| 23 | 23 |
| 24 #include "wtf/DefaultAllocator.h" | |
| 25 #include "wtf/HashTable.h" | 24 #include "wtf/HashTable.h" |
| 25 #include "wtf/PartitionAllocator.h" |
| 26 | 26 |
| 27 namespace WTF { | 27 namespace WTF { |
| 28 | 28 |
| 29 template <typename KeyTraits, typename MappedTraits> struct HashMapValueTraits; | 29 template <typename KeyTraits, typename MappedTraits> struct HashMapValueTraits; |
| 30 | 30 |
| 31 template <typename T> struct ReferenceTypeMaker { | 31 template <typename T> struct ReferenceTypeMaker { |
| 32 typedef T& ReferenceType; | 32 typedef T& ReferenceType; |
| 33 }; | 33 }; |
| 34 template <typename T> struct ReferenceTypeMaker<T&> { | 34 template <typename T> struct ReferenceTypeMaker<T&> { |
| 35 typedef T& ReferenceType; | 35 typedef T& ReferenceType; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 struct KeyValuePairKeyExtractor { | 38 struct KeyValuePairKeyExtractor { |
| 39 template <typename T> | 39 template <typename T> |
| 40 static const typename T::KeyType& extract(const T& p) { return p.key; } | 40 static const typename T::KeyType& extract(const T& p) { return p.key; } |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 // Note: empty or deleted key values are not allowed, using them may lead to | 43 // Note: empty or deleted key values are not allowed, using them may lead to |
| 44 // undefined behavior. For pointer keys this means that null pointers are not | 44 // undefined behavior. For pointer keys this means that null pointers are not |
| 45 // allowed unless you supply custom key traits. | 45 // allowed unless you supply custom key traits. |
| 46 template < | 46 template < |
| 47 typename KeyArg, | 47 typename KeyArg, |
| 48 typename MappedArg, | 48 typename MappedArg, |
| 49 typename HashArg = typename DefaultHash<KeyArg>::Hash, | 49 typename HashArg = typename DefaultHash<KeyArg>::Hash, |
| 50 typename KeyTraitsArg = HashTraits<KeyArg>, | 50 typename KeyTraitsArg = HashTraits<KeyArg>, |
| 51 typename MappedTraitsArg = HashTraits<MappedArg>, | 51 typename MappedTraitsArg = HashTraits<MappedArg>, |
| 52 typename Allocator = DefaultAllocator> | 52 typename Allocator = PartitionAllocator> |
| 53 class HashMap { | 53 class HashMap { |
| 54 WTF_USE_ALLOCATOR(HashMap, Allocator); | 54 WTF_USE_ALLOCATOR(HashMap, Allocator); |
| 55 private: | 55 private: |
| 56 typedef KeyTraitsArg KeyTraits; | 56 typedef KeyTraitsArg KeyTraits; |
| 57 typedef MappedTraitsArg MappedTraits; | 57 typedef MappedTraitsArg MappedTraits; |
| 58 typedef HashMapValueTraits<KeyTraits, MappedTraits> ValueTraits; | 58 typedef HashMapValueTraits<KeyTraits, MappedTraits> ValueTraits; |
| 59 | 59 |
| 60 public: | 60 public: |
| 61 typedef typename KeyTraits::TraitType KeyType; | 61 typedef typename KeyTraits::TraitType KeyType; |
| 62 typedef const typename KeyTraits::PeekInType& KeyPeekInType; | 62 typedef const typename KeyTraits::PeekInType& KeyPeekInType; |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 struct NeedsTracing<HashMap<T, U, V, W, X>> { | 507 struct NeedsTracing<HashMap<T, U, V, W, X>> { |
| 508 static const bool value = false; | 508 static const bool value = false; |
| 509 }; | 509 }; |
| 510 #endif | 510 #endif |
| 511 | 511 |
| 512 } // namespace WTF | 512 } // namespace WTF |
| 513 | 513 |
| 514 using WTF::HashMap; | 514 using WTF::HashMap; |
| 515 | 515 |
| 516 #endif // WTF_HashMap_h | 516 #endif // WTF_HashMap_h |
| OLD | NEW |