| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // with some other type, to avoid the cost of type conversion if the obj
ect is already | 92 // with some other type, to avoid the cost of type conversion if the obj
ect is already |
| 93 // in the table. HashTranslator must have the following function members
: | 93 // in the table. HashTranslator must have the following function members
: |
| 94 // static unsigned hash(const T&); | 94 // static unsigned hash(const T&); |
| 95 // static bool equal(const ValueType&, const T&); | 95 // static bool equal(const ValueType&, const T&); |
| 96 // static translate(ValueType&, const T&, unsigned hashCode); | 96 // static translate(ValueType&, const T&, unsigned hashCode); |
| 97 template<typename HashTranslator, typename T> AddResult add(const T&); | 97 template<typename HashTranslator, typename T> AddResult add(const T&); |
| 98 | 98 |
| 99 void remove(ValuePeekInType); | 99 void remove(ValuePeekInType); |
| 100 void remove(iterator); | 100 void remove(iterator); |
| 101 void clear(); | 101 void clear(); |
| 102 template<typename Collection> |
| 103 void removeAll(const Collection& other); |
| 102 | 104 |
| 103 static bool isValidValue(ValuePeekInType); | 105 static bool isValidValue(ValuePeekInType); |
| 104 | 106 |
| 105 void trace(typename Allocator::Visitor* visitor) | 107 void trace(typename Allocator::Visitor* visitor) |
| 106 { | 108 { |
| 107 m_impl.trace(visitor); | 109 m_impl.trace(visitor); |
| 108 } | 110 } |
| 109 | 111 |
| 110 private: | 112 private: |
| 111 friend void deleteAllValues<>(const HashSet&); | 113 friend void deleteAllValues<>(const HashSet&); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 remove(find(value)); | 213 remove(find(value)); |
| 212 } | 214 } |
| 213 | 215 |
| 214 template<typename T, typename U, typename V, typename W> | 216 template<typename T, typename U, typename V, typename W> |
| 215 inline void HashSet<T, U, V, W>::clear() | 217 inline void HashSet<T, U, V, W>::clear() |
| 216 { | 218 { |
| 217 m_impl.clear(); | 219 m_impl.clear(); |
| 218 } | 220 } |
| 219 | 221 |
| 220 template<typename T, typename U, typename V, typename W> | 222 template<typename T, typename U, typename V, typename W> |
| 223 template<typename Collection> |
| 224 inline void HashSet<T, U, V, W>::removeAll(const Collection& other) |
| 225 { |
| 226 if (other.isEmpty() || isEmpty()) |
| 227 return; |
| 228 typedef typename Collection::const_iterator CollectionIterator; |
| 229 CollectionIterator otherEnd(other.end()); |
| 230 for (CollectionIterator it(other.begin()); it != otherEnd; ++it) |
| 231 remove(*it); |
| 232 } |
| 233 |
| 234 template<typename T, typename U, typename V, typename W> |
| 221 inline bool HashSet<T, U, V, W>::isValidValue(ValuePeekInType value) | 235 inline bool HashSet<T, U, V, W>::isValidValue(ValuePeekInType value) |
| 222 { | 236 { |
| 223 if (ValueTraits::isDeletedValue(value)) | 237 if (ValueTraits::isDeletedValue(value)) |
| 224 return false; | 238 return false; |
| 225 | 239 |
| 226 if (HashFunctions::safeToCompareToEmptyOrDeleted) { | 240 if (HashFunctions::safeToCompareToEmptyOrDeleted) { |
| 227 if (value == ValueTraits::emptyValue()) | 241 if (value == ValueTraits::emptyValue()) |
| 228 return false; | 242 return false; |
| 229 } else { | 243 } else { |
| 230 if (isHashTraitsEmptyValue<ValueTraits>(value)) | 244 if (isHashTraitsEmptyValue<ValueTraits>(value)) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 260 iterator end = collection.end(); | 274 iterator end = collection.end(); |
| 261 for (unsigned i = 0; it != end; ++it, ++i) | 275 for (unsigned i = 0; it != end; ++it, ++i) |
| 262 vector[i] = *it; | 276 vector[i] = *it; |
| 263 } | 277 } |
| 264 | 278 |
| 265 } // namespace WTF | 279 } // namespace WTF |
| 266 | 280 |
| 267 using WTF::HashSet; | 281 using WTF::HashSet; |
| 268 | 282 |
| 269 #endif /* WTF_HashSet_h */ | 283 #endif /* WTF_HashSet_h */ |
| OLD | NEW |