| OLD | NEW |
| 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 * | 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 template<typename T> struct GenericHashTraits : GenericHashTraitsBase<IsInte
ger<T>::value, T> { | 70 template<typename T> struct GenericHashTraits : GenericHashTraitsBase<IsInte
ger<T>::value, T> { |
| 71 typedef T TraitType; | 71 typedef T TraitType; |
| 72 typedef T EmptyValueType; | 72 typedef T EmptyValueType; |
| 73 | 73 |
| 74 static T emptyValue() { return T(); } | 74 static T emptyValue() { return T(); } |
| 75 | 75 |
| 76 // Type for functions that do not take ownership, such as contains. | 76 // Type for functions that do not take ownership, such as contains. |
| 77 typedef const T& PeekInType; | 77 typedef const T& PeekInType; |
| 78 typedef T* IteratorGetType; |
| 79 typedef const T* IteratorConstGetType; |
| 80 typedef T& IteratorReferenceType; |
| 81 typedef const T& IteratorConstReferenceType; |
| 82 static IteratorReferenceType getToReferenceConversion(IteratorGetType x)
{ return *x; } |
| 83 static IteratorConstReferenceType getToReferenceConstConversion(Iterator
ConstGetType x) { return *x; } |
| 78 // Type for functions that take ownership, such as add. | 84 // Type for functions that take ownership, such as add. |
| 79 // The store function either not be called or called once to store somet
hing passed in. | 85 // The store function either not be called or called once to store somet
hing passed in. |
| 80 // The value passed to the store function will be PassInType. | 86 // The value passed to the store function will be PassInType. |
| 81 typedef const T& PassInType; | 87 typedef const T& PassInType; |
| 82 static void store(const T& value, T& storage) { storage = value; } | 88 static void store(const T& value, T& storage) { storage = value; } |
| 83 | 89 |
| 84 // Type for return value of functions that transfer ownership, such as t
ake. | 90 // Type for return value of functions that transfer ownership, such as t
ake. |
| 85 typedef T PassOutType; | 91 typedef T PassOutType; |
| 86 static PassOutType passOut(const T& value) { return value; } | 92 static PassOutType passOut(const T& value) { return value; } |
| 87 | 93 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 static void constructDeletedValue(T& slot) { new (NotNull, &slot) T(Hash
TableDeletedValue); } | 131 static void constructDeletedValue(T& slot) { new (NotNull, &slot) T(Hash
TableDeletedValue); } |
| 126 static bool isDeletedValue(const T& value) { return value.isHashTableDel
etedValue(); } | 132 static bool isDeletedValue(const T& value) { return value.isHashTableDel
etedValue(); } |
| 127 }; | 133 }; |
| 128 | 134 |
| 129 template<typename P> struct HashTraits<OwnPtr<P> > : SimpleClassHashTraits<O
wnPtr<P> > { | 135 template<typename P> struct HashTraits<OwnPtr<P> > : SimpleClassHashTraits<O
wnPtr<P> > { |
| 130 typedef std::nullptr_t EmptyValueType; | 136 typedef std::nullptr_t EmptyValueType; |
| 131 | 137 |
| 132 static EmptyValueType emptyValue() { return nullptr; } | 138 static EmptyValueType emptyValue() { return nullptr; } |
| 133 | 139 |
| 134 typedef const OwnPtr<P>& PeekInType; | 140 typedef const OwnPtr<P>& PeekInType; |
| 141 typedef P* IteratorGetType; |
| 142 typedef const P* IteratorConstGetType; |
| 143 typedef P& IteratorReferenceType; |
| 144 typedef const P& IteratorConstReferenceType; |
| 145 static IteratorReferenceType getToReferenceConversion(IteratorGetType x)
{ return *x; } |
| 146 static IteratorConstReferenceType getToReferenceConstConversion(Iterator
ConstGetType x) { return *x; } |
| 135 typedef PassOwnPtr<P> PassInType; | 147 typedef PassOwnPtr<P> PassInType; |
| 136 static void store(PassOwnPtr<P> value, OwnPtr<P>& storage) { storage = v
alue; } | 148 static void store(PassOwnPtr<P> value, OwnPtr<P>& storage) { storage = v
alue; } |
| 137 | 149 |
| 138 typedef PassOwnPtr<P> PassOutType; | 150 typedef PassOwnPtr<P> PassOutType; |
| 139 static PassOwnPtr<P> passOut(OwnPtr<P>& value) { return value.release();
} | 151 static PassOwnPtr<P> passOut(OwnPtr<P>& value) { return value.release();
} |
| 140 static PassOwnPtr<P> passOut(std::nullptr_t) { return nullptr; } | 152 static PassOwnPtr<P> passOut(std::nullptr_t) { return nullptr; } |
| 141 | 153 |
| 142 typedef typename OwnPtr<P>::PtrType PeekType; | 154 typedef typename OwnPtr<P>::PtrType PeekType; |
| 143 static PeekType peek(const OwnPtr<P>& value) { return value.get(); } | 155 static PeekType peek(const OwnPtr<P>& value) { return value.get(); } |
| 144 static PeekType peek(std::nullptr_t) { return 0; } | 156 static PeekType peek(std::nullptr_t) { return 0; } |
| 145 }; | 157 }; |
| 146 | 158 |
| 147 template<typename P> struct HashTraits<RefPtr<P> > : SimpleClassHashTraits<R
efPtr<P> > { | 159 template<typename P> struct HashTraits<RefPtr<P> > : SimpleClassHashTraits<R
efPtr<P> > { |
| 148 typedef const RefPtr<P>& PeekInType; | 160 typedef const RefPtr<P>& PeekInType; |
| 161 typedef RefPtr<P>* IteratorGetType; |
| 162 typedef const RefPtr<P>* IteratorConstGetType; |
| 163 typedef RefPtr<P>& IteratorReferenceType; |
| 164 typedef const RefPtr<P>& IteratorConstReferenceType; |
| 165 static IteratorReferenceType getToReferenceConversion(IteratorGetType x)
{ return *x; } |
| 166 static IteratorConstReferenceType getToReferenceConstConversion(Iterator
ConstGetType x) { return *x; } |
| 149 typedef PassRefPtr<P> PassInType; | 167 typedef PassRefPtr<P> PassInType; |
| 150 static void store(PassRefPtr<P> value, RefPtr<P>& storage) { storage = v
alue; } | 168 static void store(PassRefPtr<P> value, RefPtr<P>& storage) { storage = v
alue; } |
| 151 | 169 |
| 152 // FIXME: We should change PassOutType to PassRefPtr for better performa
nce. | 170 // FIXME: We should change PassOutType to PassRefPtr for better performa
nce. |
| 153 // FIXME: We should consider changing PeekType to a raw pointer for bett
er performance, | 171 // FIXME: We should consider changing PeekType to a raw pointer for bett
er performance, |
| 154 // but then callers won't need to call get; doing so will require updati
ng many call sites. | 172 // but then callers won't need to call get; doing so will require updati
ng many call sites. |
| 155 }; | 173 }; |
| 156 | 174 |
| 157 template<> struct HashTraits<String> : SimpleClassHashTraits<String> { | 175 template<> struct HashTraits<String> : SimpleClassHashTraits<String> { |
| 158 static const bool hasIsEmptyValueFunction = true; | 176 static const bool hasIsEmptyValueFunction = true; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 }; | 266 }; |
| 249 | 267 |
| 250 } // namespace WTF | 268 } // namespace WTF |
| 251 | 269 |
| 252 using WTF::HashTraits; | 270 using WTF::HashTraits; |
| 253 using WTF::PairHashTraits; | 271 using WTF::PairHashTraits; |
| 254 using WTF::NullableHashTraits; | 272 using WTF::NullableHashTraits; |
| 255 using WTF::SimpleClassHashTraits; | 273 using WTF::SimpleClassHashTraits; |
| 256 | 274 |
| 257 #endif // WTF_HashTraits_h | 275 #endif // WTF_HashTraits_h |
| OLD | NEW |