Changeset 11739 in webkit for trunk/JavaScriptCore/kxmlcore/HashSet.h
- Timestamp:
- Dec 22, 2005, 5:52:43 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kxmlcore/HashSet.h
r11054 r11739 31 31 32 32 template <typename T> 33 inline TidentityExtract(const T& t)33 inline const T& identityExtract(const T& t) 34 34 { 35 35 return t; 36 36 } 37 37 38 template<typename Value, typename T, Value ConvertT(const T&, unsigned)>39 inline Value convertAdapter(const T& t, const T&, unsigned h)40 {41 return ConvertT(t, h);42 }43 38 39 template<typename Value, typename T, typename HashSetTranslator> 40 struct HashSetTranslatorAdapter 41 { 42 static unsigned hash(const T& key) 43 { 44 return HashSetTranslator::hash(key); 45 } 46 47 static bool equal(const Value& a, const T& b) 48 { 49 return HashSetTranslator::equal(a, b); 50 } 51 52 static void translate(Value& location, const T& key, const T&, unsigned hashCode) 53 { 54 HashSetTranslator::translate(location, key, hashCode); 55 } 56 }; 57 44 58 template<typename Value, typename HashFunctions = DefaultHash<Value>, typename Traits = HashTraits<Value> > 45 59 class HashSet { 46 60 private: 47 typedef HashTable<Value, Value, identityExtract<Value>, HashFunctions, Traits > ImplType;61 typedef HashTable<Value, Value, identityExtract<Value>, HashFunctions, Traits, Traits> ImplType; 48 62 public: 49 63 typedef Value ValueType; … … 70 84 // a special version of insert() that finds the object by hashing and comparing 71 85 // with some other type, to avoid the cost of type conversion if the object is already 72 // in the table 73 template<typename T, unsigned HashT(const T&), bool EqualT(const ValueType&, const T&), ValueType ConvertT(const T&, unsigned)> 86 // in the table. HashTranslator should have the following methods: 87 // static unsigned hash(const T&); 88 // static bool equal(const ValueType&, const T&); 89 // static translate(ValueType&, const T&, unsigned hashCode); 90 template<typename T, typename HashTranslator> 74 91 std::pair<iterator, bool> insert(const T& value); 75 92 … … 149 166 150 167 template<typename Value, typename HashFunctions, typename Traits> 151 template<typename T, unsigned HashT(const T&), bool EqualT(const Value&, const T&), Value ConvertT(const T&, unsigned)>168 template<typename T, typename HashSetTranslator> 152 169 std::pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool> HashSet<Value, HashFunctions, Traits>::insert(const T& value) 153 170 { 154 return m_impl. insert<T, T, HashT, EqualT, convertAdapter<Value, T, ConvertT> >(value, value);171 return m_impl.template insert<T, T, HashSetTranslatorAdapter<ValueType, T, HashSetTranslator> >(value, value); 155 172 } 156 173
Note:
See TracChangeset
for help on using the changeset viewer.