| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // static bool equal(const ValueType&, const T&); | 101 // static bool equal(const ValueType&, const T&); |
| 102 template <typename HashTranslator, typename T> | 102 template <typename HashTranslator, typename T> |
| 103 iterator find(const T&) const; | 103 iterator find(const T&) const; |
| 104 template <typename HashTranslator, typename T> | 104 template <typename HashTranslator, typename T> |
| 105 bool contains(const T&) const; | 105 bool contains(const T&) const; |
| 106 | 106 |
| 107 // The return value is a pair of an iterator to the new value's location, | 107 // The return value is a pair of an iterator to the new value's location, |
| 108 // and a bool that is true if an new entry was added. | 108 // and a bool that is true if an new entry was added. |
| 109 template <typename IncomingValueType> | 109 template <typename IncomingValueType> |
| 110 AddResult insert(IncomingValueType&&); | 110 AddResult insert(IncomingValueType&&); |
| 111 template <typename IncomingValueType> | 111 // TODO(pilgrim) remove this |
| 112 AddResult add(IncomingValueType&&); | 112 // template <typename IncomingValueType> |
| 113 // AddResult add(IncomingValueType&&); |
| 113 | 114 |
| 114 // An alternate version of add() that finds the object by hashing and | 115 // An alternate version of add() that finds the object by hashing and |
| 115 // comparing with some other type, to avoid the cost of type conversion if | 116 // comparing with some other type, to avoid the cost of type conversion if |
| 116 // the object is already in the table. HashTranslator must have the | 117 // the object is already in the table. HashTranslator must have the |
| 117 // following function members: | 118 // following function members: |
| 118 // static unsigned hash(const T&); | 119 // static unsigned hash(const T&); |
| 119 // static bool equal(const ValueType&, const T&); | 120 // static bool equal(const ValueType&, const T&); |
| 120 // static translate(ValueType&, T&&, unsigned hashCode); | 121 // static translate(ValueType&, T&&, unsigned hashCode); |
| 121 template <typename HashTranslator, typename T> | 122 template <typename HashTranslator, typename T> |
| 122 AddResult addWithTranslator(T&&); | 123 AddResult addWithTranslator(T&&); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 value); | 253 value); |
| 253 } | 254 } |
| 254 | 255 |
| 255 template <typename T, typename U, typename V, typename W> | 256 template <typename T, typename U, typename V, typename W> |
| 256 template <typename IncomingValueType> | 257 template <typename IncomingValueType> |
| 257 inline typename HashSet<T, U, V, W>::AddResult HashSet<T, U, V, W>::insert( | 258 inline typename HashSet<T, U, V, W>::AddResult HashSet<T, U, V, W>::insert( |
| 258 IncomingValueType&& value) { | 259 IncomingValueType&& value) { |
| 259 return m_impl.add(std::forward<IncomingValueType>(value)); | 260 return m_impl.add(std::forward<IncomingValueType>(value)); |
| 260 } | 261 } |
| 261 | 262 |
| 262 // TODO(pilgrim) remove this method once all references and subclasses | |
| 263 // have been migrated to insert() method | |
| 264 template <typename T, typename U, typename V, typename W> | |
| 265 template <typename IncomingValueType> | |
| 266 inline typename HashSet<T, U, V, W>::AddResult HashSet<T, U, V, W>::add( | |
| 267 IncomingValueType&& value) { | |
| 268 return m_impl.add(std::forward<IncomingValueType>(value)); | |
| 269 } | |
| 270 | |
| 271 template <typename Value, | 263 template <typename Value, |
| 272 typename HashFunctions, | 264 typename HashFunctions, |
| 273 typename Traits, | 265 typename Traits, |
| 274 typename Allocator> | 266 typename Allocator> |
| 275 template <typename HashTranslator, typename T> | 267 template <typename HashTranslator, typename T> |
| 276 inline typename HashSet<Value, HashFunctions, Traits, Allocator>::AddResult | 268 inline typename HashSet<Value, HashFunctions, Traits, Allocator>::AddResult |
| 277 HashSet<Value, HashFunctions, Traits, Allocator>::addWithTranslator(T&& value) { | 269 HashSet<Value, HashFunctions, Traits, Allocator>::addWithTranslator(T&& value) { |
| 278 // Forward only the first argument, because the second argument isn't actually | 270 // Forward only the first argument, because the second argument isn't actually |
| 279 // used in HashSetTranslatorAdapter. | 271 // used in HashSetTranslatorAdapter. |
| 280 return m_impl | 272 return m_impl |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 iterator end = collection.end(); | 324 iterator end = collection.end(); |
| 333 for (unsigned i = 0; it != end; ++it, ++i) | 325 for (unsigned i = 0; it != end; ++it, ++i) |
| 334 vector[i] = *it; | 326 vector[i] = *it; |
| 335 } | 327 } |
| 336 | 328 |
| 337 } // namespace WTF | 329 } // namespace WTF |
| 338 | 330 |
| 339 using WTF::HashSet; | 331 using WTF::HashSet; |
| 340 | 332 |
| 341 #endif // WTF_HashSet_h | 333 #endif // WTF_HashSet_h |
| OLD | NEW |