Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: third_party/WebKit/Source/wtf/HashMap.h

Issue 2518253002: Move Partition Allocator into Chromium base. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/allocator/partition_allocator/partition_allocator.h"
24 #include "wtf/HashTable.h" 25 #include "wtf/HashTable.h"
25 #include "wtf/allocator/PartitionAllocator.h"
26 26
27 namespace WTF { 27 namespace WTF {
28 28
29 template <typename KeyTraits, typename MappedTraits> 29 template <typename KeyTraits, typename MappedTraits>
30 struct HashMapValueTraits; 30 struct HashMapValueTraits;
31 31
32 struct KeyValuePairKeyExtractor { 32 struct KeyValuePairKeyExtractor {
33 STATIC_ONLY(KeyValuePairKeyExtractor); 33 STATIC_ONLY(KeyValuePairKeyExtractor);
34 template <typename T> 34 template <typename T>
35 static const typename T::KeyType& extract(const T& p) { 35 static const typename T::KeyType& extract(const T& p) {
36 return p.key; 36 return p.key;
37 } 37 }
38 }; 38 };
39 39
40 // Note: empty or deleted key values are not allowed, using them may lead to 40 // Note: empty or deleted key values are not allowed, using them may lead to
41 // undefined behavior. For pointer keys this means that null pointers are not 41 // undefined behavior. For pointer keys this means that null pointers are not
42 // allowed unless you supply custom key traits. 42 // allowed unless you supply custom key traits.
43 template <typename KeyArg, 43 template <typename KeyArg,
44 typename MappedArg, 44 typename MappedArg,
45 typename HashArg = typename DefaultHash<KeyArg>::Hash, 45 typename HashArg = typename DefaultHash<KeyArg>::Hash,
46 typename KeyTraitsArg = HashTraits<KeyArg>, 46 typename KeyTraitsArg = HashTraits<KeyArg>,
47 typename MappedTraitsArg = HashTraits<MappedArg>, 47 typename MappedTraitsArg = HashTraits<MappedArg>,
48 typename Allocator = PartitionAllocator> 48 typename Allocator = PartitionAllocator>
49 class HashMap { 49 class HashMap {
50 WTF_USE_ALLOCATOR(HashMap, Allocator); 50 USE_ALLOCATOR(HashMap, Allocator);
51 51
52 private: 52 private:
53 typedef KeyTraitsArg KeyTraits; 53 typedef KeyTraitsArg KeyTraits;
54 typedef MappedTraitsArg MappedTraits; 54 typedef MappedTraitsArg MappedTraits;
55 typedef HashMapValueTraits<KeyTraits, MappedTraits> ValueTraits; 55 typedef HashMapValueTraits<KeyTraits, MappedTraits> ValueTraits;
56 56
57 public: 57 public:
58 typedef typename KeyTraits::TraitType KeyType; 58 typedef typename KeyTraits::TraitType KeyType;
59 typedef const typename KeyTraits::PeekInType& KeyPeekInType; 59 typedef const typename KeyTraits::PeekInType& KeyPeekInType;
60 typedef typename MappedTraits::TraitType MappedType; 60 typedef typename MappedTraits::TraitType MappedType;
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 iterator end = collection.end().values(); 690 iterator end = collection.end().values();
691 for (unsigned i = 0; it != end; ++it, ++i) 691 for (unsigned i = 0; it != end; ++it, ++i)
692 vector[i] = *it; 692 vector[i] = *it;
693 } 693 }
694 694
695 } // namespace WTF 695 } // namespace WTF
696 696
697 using WTF::HashMap; 697 using WTF::HashMap;
698 698
699 #endif // WTF_HashMap_h 699 #endif // WTF_HashMap_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698