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

Side by Side Diff: Source/wtf/HashTable.h

Issue 131803005: Add more oilpan collections support (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix OtherType for Windows compielr Created 6 years, 10 months 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 | Annotate | Revision Log
OLDNEW
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 * Copyright (C) 2008 David Levin <levin@chromium.org> 3 * Copyright (C) 2008 David Levin <levin@chromium.org>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 196 }
197 197
198 template<typename T, bool useSwap> struct Mover; 198 template<typename T, bool useSwap> struct Mover;
199 template<typename T> struct Mover<T, true> { static void move(T& from, T& to ) { hashTableSwap(from, to); } }; 199 template<typename T> struct Mover<T, true> { static void move(T& from, T& to ) { hashTableSwap(from, to); } };
200 template<typename T> struct Mover<T, false> { static void move(T& from, T& t o) { to = from; } }; 200 template<typename T> struct Mover<T, false> { static void move(T& from, T& t o) { to = from; } };
201 201
202 template<typename HashFunctions> class IdentityHashTranslator { 202 template<typename HashFunctions> class IdentityHashTranslator {
203 public: 203 public:
204 template<typename T> static unsigned hash(const T& key) { return HashFun ctions::hash(key); } 204 template<typename T> static unsigned hash(const T& key) { return HashFun ctions::hash(key); }
205 template<typename T, typename U> static bool equal(const T& a, const U& b) { return HashFunctions::equal(a, b); } 205 template<typename T, typename U> static bool equal(const T& a, const U& b) { return HashFunctions::equal(a, b); }
206 template<typename T, typename U> static void translate(T& location, cons t U&, const T& value) { location = value; } 206 template<typename T, typename U, typename V> static void translate(T& lo cation, const U&, const V& value) { location = value; }
207 }; 207 };
208 208
209 template<typename IteratorType> struct HashTableAddResult { 209 template<typename IteratorType> struct HashTableAddResult {
210 HashTableAddResult(IteratorType iter, bool isNewEntry) : iterator(iter), isNewEntry(isNewEntry) { } 210 HashTableAddResult(IteratorType iter, bool isNewEntry) : iterator(iter), isNewEntry(isNewEntry) { }
211 IteratorType iterator; 211 IteratorType iterator;
212 bool isNewEntry; 212 bool isNewEntry;
213 }; 213 };
214 214
215 template<typename Value, typename Extractor, typename KeyTraits> 215 template<typename Value, typename Extractor, typename KeyTraits>
216 struct HashTableHelper { 216 struct HashTableHelper {
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 // while we are iterating over them. The weakProcessing callback will 1061 // while we are iterating over them. The weakProcessing callback will
1062 // mark the backing as a void pointer, and will perform weak processing 1062 // mark the backing as a void pointer, and will perform weak processing
1063 // if needed. 1063 // if needed.
1064 if (!Traits::isWeak) 1064 if (!Traits::isWeak)
1065 Allocator::markNoTracing(visitor, m_table); 1065 Allocator::markNoTracing(visitor, m_table);
1066 else 1066 else
1067 Allocator::registerWeakMembers(visitor, this, WeakProcessingHashTabl eHelper<Traits::isWeak, Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::process); 1067 Allocator::registerWeakMembers(visitor, this, WeakProcessingHashTabl eHelper<Traits::isWeak, Key, Value, Extractor, HashFunctions, Traits, KeyTraits, Allocator>::process);
1068 if (Traits::needsTracing) { 1068 if (Traits::needsTracing) {
1069 for (ValueType* element = m_table + m_tableSize - 1; element >= m_ta ble; element--) { 1069 for (ValueType* element = m_table + m_tableSize - 1; element >= m_ta ble; element--) {
1070 if (!isEmptyOrDeletedBucket(*element)) 1070 if (!isEmptyOrDeletedBucket(*element))
1071 Allocator::template mark<ValueType, Traits>(visitor, *elemen t); 1071 Allocator::template trace<ValueType, Traits>(visitor, *eleme nt);
1072 } 1072 }
1073 } 1073 }
1074 } 1074 }
1075 1075
1076 // iterator adapters 1076 // iterator adapters
1077 1077
1078 template<typename HashTableType, typename Traits> struct HashTableConstItera torAdapter { 1078 template<typename HashTableType, typename Traits> struct HashTableConstItera torAdapter {
1079 HashTableConstIteratorAdapter() {} 1079 HashTableConstIteratorAdapter() {}
1080 HashTableConstIteratorAdapter(const typename HashTableType::const_iterat or& impl) : m_impl(impl) {} 1080 HashTableConstIteratorAdapter(const typename HashTableType::const_iterat or& impl) : m_impl(impl) {}
1081 typedef typename Traits::IteratorConstGetType GetType; 1081 typedef typename Traits::IteratorConstGetType GetType;
1082 typedef typename HashTableType::ValueTraits::IteratorConstGetType Source GetType; 1082 typedef typename HashTableType::ValueTraits::IteratorConstGetType Source GetType;
1083 1083
1084 GetType get() const { return (GetType)SourceGetType(m_impl.get()); } 1084 GetType get() const { return const_cast<GetType>(SourceGetType(m_impl.ge t())); }
1085 typename Traits::IteratorConstReferenceType operator*() const { return T raits::getToReferenceConstConversion(get()); } 1085 typename Traits::IteratorConstReferenceType operator*() const { return T raits::getToReferenceConstConversion(get()); }
1086 GetType operator->() const { return get(); } 1086 GetType operator->() const { return get(); }
1087 1087
1088 HashTableConstIteratorAdapter& operator++() { ++m_impl; return *this; } 1088 HashTableConstIteratorAdapter& operator++() { ++m_impl; return *this; }
1089 // postfix ++ intentionally omitted 1089 // postfix ++ intentionally omitted
1090 1090
1091 typename HashTableType::const_iterator m_impl; 1091 typename HashTableType::const_iterator m_impl;
1092 }; 1092 };
1093 1093
1094 template<typename HashTableType, typename Traits> struct HashTableIteratorAd apter { 1094 template<typename HashTableType, typename Traits> struct HashTableIteratorAd apter {
1095 typedef typename Traits::IteratorGetType GetType; 1095 typedef typename Traits::IteratorGetType GetType;
1096 typedef typename HashTableType::ValueTraits::IteratorGetType SourceGetTy pe; 1096 typedef typename HashTableType::ValueTraits::IteratorGetType SourceGetTy pe;
1097 1097
1098 HashTableIteratorAdapter() {} 1098 HashTableIteratorAdapter() {}
1099 HashTableIteratorAdapter(const typename HashTableType::iterator& impl) : m_impl(impl) {} 1099 HashTableIteratorAdapter(const typename HashTableType::iterator& impl) : m_impl(impl) {}
1100 1100
1101 GetType get() const { return (GetType)SourceGetType(m_impl.get()); } 1101 GetType get() const { return const_cast<GetType>(SourceGetType(m_impl.ge t())); }
1102 typename Traits::IteratorReferenceType operator*() const { return Traits ::getToReferenceConversion(get()); } 1102 typename Traits::IteratorReferenceType operator*() const { return Traits ::getToReferenceConversion(get()); }
1103 GetType operator->() const { return get(); } 1103 GetType operator->() const { return get(); }
1104 1104
1105 HashTableIteratorAdapter& operator++() { ++m_impl; return *this; } 1105 HashTableIteratorAdapter& operator++() { ++m_impl; return *this; }
1106 // postfix ++ intentionally omitted 1106 // postfix ++ intentionally omitted
1107 1107
1108 operator HashTableConstIteratorAdapter<HashTableType, Traits>() 1108 operator HashTableConstIteratorAdapter<HashTableType, Traits>()
1109 { 1109 {
1110 typename HashTableType::const_iterator i = m_impl; 1110 typename HashTableType::const_iterator i = m_impl;
1111 return i; 1111 return i;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 inline bool operator!=(const HashTableIteratorAdapter<T, U>& a, const HashTa bleConstIteratorAdapter<T, U>& b) 1161 inline bool operator!=(const HashTableIteratorAdapter<T, U>& a, const HashTa bleConstIteratorAdapter<T, U>& b)
1162 { 1162 {
1163 return a.m_impl != b.m_impl; 1163 return a.m_impl != b.m_impl;
1164 } 1164 }
1165 1165
1166 } // namespace WTF 1166 } // namespace WTF
1167 1167
1168 #include "wtf/HashIterators.h" 1168 #include "wtf/HashIterators.h"
1169 1169
1170 #endif // WTF_HashTable_h 1170 #endif // WTF_HashTable_h
OLDNEW
« Source/heap/Heap.h ('K') | « Source/wtf/HashSet.h ('k') | Source/wtf/Vector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698