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

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

Issue 183833009: Oilpan: Allowing hashing of RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 static const bool safeToCompareToEmptyOrDeleted = true; 136 static const bool safeToCompareToEmptyOrDeleted = true;
137 }; 137 };
138 template<typename P> struct PtrHash<RefPtr<P> > : PtrHash<P*> { 138 template<typename P> struct PtrHash<RefPtr<P> > : PtrHash<P*> {
139 using PtrHash<P*>::hash; 139 using PtrHash<P*>::hash;
140 static unsigned hash(const RefPtr<P>& key) { return hash(key.get()); } 140 static unsigned hash(const RefPtr<P>& key) { return hash(key.get()); }
141 using PtrHash<P*>::equal; 141 using PtrHash<P*>::equal;
142 static bool equal(const RefPtr<P>& a, const RefPtr<P>& b) { return a == b; } 142 static bool equal(const RefPtr<P>& a, const RefPtr<P>& b) { return a == b; }
143 static bool equal(P* a, const RefPtr<P>& b) { return a == b; } 143 static bool equal(P* a, const RefPtr<P>& b) { return a == b; }
144 static bool equal(const RefPtr<P>& a, P* b) { return a == b; } 144 static bool equal(const RefPtr<P>& a, P* b) { return a == b; }
145 }; 145 };
146 template<typename P> struct PtrHash<RawPtr<P> > : PtrHash<P*> {
147 using PtrHash<P*>::hash;
148 static unsigned hash(const RawPtr<P>& key) { return hash(key.get()); }
149 using PtrHash<P*>::equal;
150 static bool equal(const RawPtr<P>& a, const RawPtr<P>& b) { return a == b; }
151 static bool equal(P* a, const RawPtr<P>& b) { return a == b; }
152 static bool equal(const RawPtr<P>& a, P* b) { return a == b; }
153 };
146 154
147 // default hash function for each type 155 // default hash function for each type
148 156
149 template<typename T> struct DefaultHash; 157 template<typename T> struct DefaultHash;
150 158
151 template<typename T, typename U> struct PairHash { 159 template<typename T, typename U> struct PairHash {
152 static unsigned hash(const std::pair<T, U>& p) 160 static unsigned hash(const std::pair<T, U>& p)
153 { 161 {
154 return pairIntHash(DefaultHash<T>::Hash::hash(p.first), DefaultHash< U>::Hash::hash(p.second)); 162 return pairIntHash(DefaultHash<T>::Hash::hash(p.first), DefaultHash< U>::Hash::hash(p.second));
155 } 163 }
(...skipping 26 matching lines...) Expand all
182 template<> struct DefaultHash<wchar_t> { typedef IntHash<wchar_t> Hash; }; 190 template<> struct DefaultHash<wchar_t> { typedef IntHash<wchar_t> Hash; };
183 #endif 191 #endif
184 192
185 template<> struct DefaultHash<float> { typedef FloatHash<float> Hash; }; 193 template<> struct DefaultHash<float> { typedef FloatHash<float> Hash; };
186 template<> struct DefaultHash<double> { typedef FloatHash<double> Hash; }; 194 template<> struct DefaultHash<double> { typedef FloatHash<double> Hash; };
187 195
188 // make PtrHash the default hash function for pointer types that don't speci alize 196 // make PtrHash the default hash function for pointer types that don't speci alize
189 197
190 template<typename P> struct DefaultHash<P*> { typedef PtrHash<P*> Hash; }; 198 template<typename P> struct DefaultHash<P*> { typedef PtrHash<P*> Hash; };
191 template<typename P> struct DefaultHash<RefPtr<P> > { typedef PtrHash<RefPtr <P> > Hash; }; 199 template<typename P> struct DefaultHash<RefPtr<P> > { typedef PtrHash<RefPtr <P> > Hash; };
200 template<typename P> struct DefaultHash<RawPtr<P> > { typedef PtrHash<RawPtr <P> > Hash; };
192 201
193 // make IntPairHash the default hash function for pairs of (at most) 32-bit integers. 202 // make IntPairHash the default hash function for pairs of (at most) 32-bit integers.
194 203
195 template<> struct DefaultHash<std::pair<short, short> > { typedef IntPairHas h<short, short> Hash; }; 204 template<> struct DefaultHash<std::pair<short, short> > { typedef IntPairHas h<short, short> Hash; };
196 template<> struct DefaultHash<std::pair<short, unsigned short> > { typedef I ntPairHash<short, unsigned short> Hash; }; 205 template<> struct DefaultHash<std::pair<short, unsigned short> > { typedef I ntPairHash<short, unsigned short> Hash; };
197 template<> struct DefaultHash<std::pair<short, int> > { typedef IntPairHash< short, int> Hash; }; 206 template<> struct DefaultHash<std::pair<short, int> > { typedef IntPairHash< short, int> Hash; };
198 template<> struct DefaultHash<std::pair<short, unsigned> > { typedef IntPair Hash<short, unsigned> Hash; }; 207 template<> struct DefaultHash<std::pair<short, unsigned> > { typedef IntPair Hash<short, unsigned> Hash; };
199 template<> struct DefaultHash<std::pair<unsigned short, short> > { typedef I ntPairHash<unsigned short, short> Hash; }; 208 template<> struct DefaultHash<std::pair<unsigned short, short> > { typedef I ntPairHash<unsigned short, short> Hash; };
200 template<> struct DefaultHash<std::pair<unsigned short, unsigned short> > { typedef IntPairHash<unsigned short, unsigned short> Hash; }; 209 template<> struct DefaultHash<std::pair<unsigned short, unsigned short> > { typedef IntPairHash<unsigned short, unsigned short> Hash; };
201 template<> struct DefaultHash<std::pair<unsigned short, int> > { typedef Int PairHash<unsigned short, int> Hash; }; 210 template<> struct DefaultHash<std::pair<unsigned short, int> > { typedef Int PairHash<unsigned short, int> Hash; };
(...skipping 11 matching lines...) Expand all
213 222
214 template<typename T, typename U> struct DefaultHash<std::pair<T, U> > { type def PairHash<T, U> Hash; }; 223 template<typename T, typename U> struct DefaultHash<std::pair<T, U> > { type def PairHash<T, U> Hash; };
215 224
216 } // namespace WTF 225 } // namespace WTF
217 226
218 using WTF::DefaultHash; 227 using WTF::DefaultHash;
219 using WTF::IntHash; 228 using WTF::IntHash;
220 using WTF::PtrHash; 229 using WTF::PtrHash;
221 230
222 #endif // WTF_HashFunctions_h 231 #endif // WTF_HashFunctions_h
OLDNEW
« no previous file with comments | « Source/heap/HeapTest.cpp ('k') | Source/wtf/HashTraits.h » ('j') | Source/wtf/HashTraits.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698