Changeset 101806 in webkit for trunk/Source/JavaScriptCore/wtf/HashSet.h
- Timestamp:
- Dec 2, 2011, 8:50:32 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/wtf/HashSet.h
r76425 r101806 1 1 /* 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 27 27 namespace WTF { 28 28 29 struct IdentityExtractor; 30 29 31 template<typename Value, typename HashFunctions, typename Traits> class HashSet; 30 32 template<typename Value, typename HashFunctions, typename Traits> … … 32 34 template<typename Value, typename HashFunctions, typename Traits> 33 35 void fastDeleteAllValues(const HashSet<Value, HashFunctions, Traits>&); 34 35 template<typename T> struct IdentityExtractor;36 36 37 37 template<typename ValueArg, typename HashArg = typename DefaultHash<ValueArg>::Hash, … … 46 46 47 47 private: 48 typedef HashTable<ValueType, ValueType, IdentityExtractor <ValueType>,48 typedef HashTable<ValueType, ValueType, IdentityExtractor, 49 49 HashFunctions, ValueTraits, ValueTraits> HashTableType; 50 50 … … 70 70 // static unsigned hash(const T&); 71 71 // static bool equal(const ValueType&, const T&); 72 // FIXME: We should reverse the order of the template arguments so that callers 73 // can just pass the translator and let the compiler deduce T. 72 74 template<typename T, typename HashTranslator> iterator find(const T&) const; 73 75 template<typename T, typename HashTranslator> bool contains(const T&) const; … … 83 85 // static bool equal(const ValueType&, const T&); 84 86 // static translate(ValueType&, const T&, unsigned hashCode); 87 // FIXME: We should reverse the order of the template arguments so that callers 88 // can just pass the translator and let the compiler deduce T. 85 89 template<typename T, typename HashTranslator> pair<iterator, bool> add(const T&); 86 90 … … 96 100 }; 97 101 98 template<typename T>struct IdentityExtractor {99 static const T& extract(const T& t) { return t; }102 struct IdentityExtractor { 103 template<typename T> static const T& extract(const T& t) { return t; } 100 104 }; 101 105 102 template<typename ValueType, typename ValueTraits, typename T, typenameTranslator>106 template<typename Translator> 103 107 struct HashSetTranslatorAdapter { 104 static unsigned hash(const T& key) { return Translator::hash(key); }105 static bool equal(const ValueType& a, const T& b) { return Translator::equal(a, b); }106 static void translate(ValueType& location, const T& key, const T&, unsigned hashCode)108 template<typename T> static unsigned hash(const T& key) { return Translator::hash(key); } 109 template<typename T, typename U> static bool equal(const T& a, const U& b) { return Translator::equal(a, b); } 110 template<typename T, typename U> static void translate(T& location, const U& key, const U&, unsigned hashCode) 107 111 { 108 112 Translator::translate(location, key, hashCode); … … 163 167 inline HashSet<Value, HashFunctions, Traits>::find(const T& value) const 164 168 { 165 typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter; 166 return m_impl.template find<T, Adapter>(value); 169 return m_impl.template find<HashSetTranslatorAdapter<HashTranslator> >(value); 167 170 } 168 171 … … 171 174 inline bool HashSet<Value, HashFunctions, Traits>::contains(const T& value) const 172 175 { 173 typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter; 174 return m_impl.template contains<T, Adapter>(value); 176 return m_impl.template contains<HashSetTranslatorAdapter<HashTranslator> >(value); 175 177 } 176 178 … … 186 188 HashSet<Value, HashFunctions, Traits>::add(const T& value) 187 189 { 188 typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter; 189 return m_impl.template addPassingHashCode<T, T, Adapter>(value, value); 190 return m_impl.template addPassingHashCode<HashSetTranslatorAdapter<HashTranslator> >(value, value); 190 191 } 191 192
Note:
See TracChangeset
for help on using the changeset viewer.