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 24 matching lines...) Expand all Loading... |
35 template<typename T> class OwnPtr; | 35 template<typename T> class OwnPtr; |
36 template<typename T> class PassOwnPtr; | 36 template<typename T> class PassOwnPtr; |
37 | 37 |
38 template<typename T> struct HashTraits; | 38 template<typename T> struct HashTraits; |
39 | 39 |
40 template<bool isInteger, typename T> struct GenericHashTraitsBase; | 40 template<bool isInteger, typename T> struct GenericHashTraitsBase; |
41 | 41 |
42 template<typename T> struct GenericHashTraitsBase<false, T> { | 42 template<typename T> struct GenericHashTraitsBase<false, T> { |
43 // The emptyValueIsZero flag is used to optimize allocation of empty has
h tables with zeroed memory. | 43 // The emptyValueIsZero flag is used to optimize allocation of empty has
h tables with zeroed memory. |
44 static const bool emptyValueIsZero = false; | 44 static const bool emptyValueIsZero = false; |
45 | 45 |
46 // The hasIsEmptyValueFunction flag allows the hash table to automatical
ly generate code to check | 46 // The hasIsEmptyValueFunction flag allows the hash table to automatical
ly generate code to check |
47 // for the empty value when it can be done with the equality operator, b
ut allows custom functions | 47 // for the empty value when it can be done with the equality operator, b
ut allows custom functions |
48 // for cases like String that need them. | 48 // for cases like String that need them. |
49 static const bool hasIsEmptyValueFunction = false; | 49 static const bool hasIsEmptyValueFunction = false; |
50 | 50 |
51 // The needsDestruction flag is used to optimize destruction and rehashi
ng. | 51 // The needsDestruction flag is used to optimize destruction and rehashi
ng. |
52 static const bool needsDestruction = true; | 52 static const bool needsDestruction = true; |
53 | 53 |
54 // The starting table size. Can be overridden when we know beforehand th
at | 54 // The starting table size. Can be overridden when we know beforehand th
at |
55 // a hash table will have at least N entries. | 55 // a hash table will have at least N entries. |
(...skipping 13 matching lines...) Expand all Loading... |
69 typedef T EmptyValueType; | 69 typedef T EmptyValueType; |
70 | 70 |
71 static T emptyValue() { return T(); } | 71 static T emptyValue() { return T(); } |
72 | 72 |
73 // Type for functions that take ownership, such as add. | 73 // Type for functions that take ownership, such as add. |
74 // The store function either not be called or called once to store somet
hing passed in. | 74 // The store function either not be called or called once to store somet
hing passed in. |
75 // The value passed to the store function will be either PassInType or P
assInType&. | 75 // The value passed to the store function will be either PassInType or P
assInType&. |
76 typedef const T& PassInType; | 76 typedef const T& PassInType; |
77 static void store(const T& value, T& storage) { storage = value; } | 77 static void store(const T& value, T& storage) { storage = value; } |
78 | 78 |
79 // Type for return value of functions that transfer ownership, such as t
ake. | 79 // Type for return value of functions that transfer ownership, such as t
ake. |
80 typedef T PassOutType; | 80 typedef T PassOutType; |
81 static PassOutType passOut(const T& value) { return value; } | 81 static PassOutType passOut(const T& value) { return value; } |
82 static T& passOut(T& value) { return value; } // Overloaded to avoid cop
ying of non-temporary values. | 82 static T& passOut(T& value) { return value; } // Overloaded to avoid cop
ying of non-temporary values. |
83 | 83 |
84 // Type for return value of functions that do not transfer ownership, su
ch as get. | 84 // Type for return value of functions that do not transfer ownership, su
ch as get. |
85 // FIXME: We could change this type to const T& for better performance i
f we figured out | 85 // FIXME: We could change this type to const T& for better performance i
f we figured out |
86 // a way to handle the return value from emptyValue, which is a temporar
y. | 86 // a way to handle the return value from emptyValue, which is a temporar
y. |
87 typedef T PeekType; | 87 typedef T PeekType; |
88 static PeekType peek(const T& value) { return value; } | 88 static PeekType peek(const T& value) { return value; } |
89 static T& peek(T& value) { return value; } // Overloaded to avoid copyin
g of non-temporary values. | 89 static T& peek(T& value) { return value; } // Overloaded to avoid copyin
g of non-temporary values. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 }; | 248 }; |
249 | 249 |
250 } // namespace WTF | 250 } // namespace WTF |
251 | 251 |
252 using WTF::HashTraits; | 252 using WTF::HashTraits; |
253 using WTF::PairHashTraits; | 253 using WTF::PairHashTraits; |
254 using WTF::NullableHashTraits; | 254 using WTF::NullableHashTraits; |
255 using WTF::SimpleClassHashTraits; | 255 using WTF::SimpleClassHashTraits; |
256 | 256 |
257 #endif // WTF_HashTraits_h | 257 #endif // WTF_HashTraits_h |
OLD | NEW |