Changeset 96733 in webkit for trunk/Source/JavaScriptCore/wtf
- Timestamp:
- Oct 5, 2011, 11:29:58 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/wtf/ListHashSet.h
r96648 r96733 28 28 #include "PassOwnPtr.h" 29 29 #include "StdLibExtras.h" 30 #include <iterator> 30 31 31 32 namespace WTF { … … 50 51 template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetIterator; 51 52 template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetConstIterator; 52 template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetReverseIterator;53 template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetConstReverseIterator;54 53 55 54 template<typename ValueArg, size_t inlineCapacity> struct ListHashSetNode; … … 79 78 friend class ListHashSetConstIterator<ValueType, inlineCapacity, HashArg>; 80 79 81 typedef ListHashSetReverseIterator<ValueType, inlineCapacity, HashArg> reverse_iterator; 82 typedef ListHashSetConstReverseIterator<ValueType, inlineCapacity, HashArg> const_reverse_iterator; 83 friend class ListHashSetConstReverseIterator<ValueType, inlineCapacity, HashArg>; 80 typedef std::reverse_iterator<iterator> reverse_iterator; 81 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 84 82 85 83 ListHashSet(); … … 141 139 iterator makeIterator(Node*); 142 140 const_iterator makeConstIterator(Node*) const; 143 reverse_iterator makeReverseIterator(Node*);144 const_reverse_iterator makeConstReverseIterator(Node*) const;145 141 146 142 friend void deleteAllValues<>(const ListHashSet&); … … 272 268 273 269 friend class ListHashSet<ValueArg, inlineCapacity, HashArg>; 274 270 275 271 ListHashSetIterator(const ListHashSetType* set, Node* position) : m_iterator(set, position) { } 276 272 277 273 public: 274 typedef std::bidirectional_iterator_tag iterator_category; 275 typedef ValueType value_type; 276 typedef ReferenceType reference; 277 typedef PointerType pointer; 278 typedef int difference_type; 279 278 280 ListHashSetIterator() { } 279 281 … … 324 326 325 327 public: 328 typedef std::bidirectional_iterator_tag iterator_category; 329 typedef ValueType value_type; 330 typedef ReferenceType reference; 331 typedef PointerType pointer; 332 typedef int difference_type; 333 326 334 ListHashSetConstIterator() 327 335 { … … 373 381 }; 374 382 375 template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetReverseIterator {376 private:377 typedef ListHashSet<ValueArg, inlineCapacity, HashArg> ListHashSetType;378 typedef ListHashSetReverseIterator<ValueArg, inlineCapacity, HashArg> reverse_iterator;379 typedef ListHashSetConstIterator<ValueArg, inlineCapacity, HashArg> const_reverse_iterator;380 typedef ListHashSetNode<ValueArg, inlineCapacity> Node;381 typedef ValueArg ValueType;382 typedef ValueType& ReferenceType;383 typedef ValueType* PointerType;384 385 friend class ListHashSet<ValueArg, inlineCapacity, HashArg>;386 387 ListHashSetReverseIterator(const ListHashSetType* set, Node* position) : m_iterator(set, position) { }388 389 public:390 ListHashSetReverseIterator() { }391 392 // default copy, assignment and destructor are OK393 394 PointerType get() const { return const_cast<PointerType>(m_iterator.get()); }395 ReferenceType operator*() const { return *get(); }396 PointerType operator->() const { return get(); }397 398 reverse_iterator& operator++() { ++m_iterator; return *this; }399 400 // postfix ++ intentionally omitted401 402 reverse_iterator& operator--() { --m_iterator; return *this; }403 404 // postfix -- intentionally omitted405 406 // Comparison.407 bool operator==(const reverse_iterator& other) const { return m_iterator == other.m_iterator; }408 bool operator!=(const reverse_iterator& other) const { return m_iterator != other.m_iterator; }409 410 operator const_reverse_iterator() const { return m_iterator; }411 412 private:413 Node* node() { return m_iterator.node(); }414 415 const_reverse_iterator m_iterator;416 };417 418 template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetConstReverseIterator {419 private:420 typedef ListHashSet<ValueArg, inlineCapacity, HashArg> ListHashSetType;421 typedef ListHashSetReverseIterator<ValueArg, inlineCapacity, HashArg> reverse_iterator;422 typedef ListHashSetConstReverseIterator<ValueArg, inlineCapacity, HashArg> const_reverse_iterator;423 typedef ListHashSetNode<ValueArg, inlineCapacity> Node;424 typedef ValueArg ValueType;425 typedef const ValueType& ReferenceType;426 typedef const ValueType* PointerType;427 428 friend class ListHashSet<ValueArg, inlineCapacity, HashArg>;429 friend class ListHashSetReverseIterator<ValueArg, inlineCapacity, HashArg>;430 431 ListHashSetConstReverseIterator(const ListHashSetType* set, Node* position)432 : m_set(set)433 , m_position(position)434 {435 }436 437 public:438 ListHashSetConstReverseIterator()439 {440 }441 442 PointerType get() const443 {444 return &m_position->m_value;445 }446 ReferenceType operator*() const { return *get(); }447 PointerType operator->() const { return get(); }448 449 const_reverse_iterator& operator++()450 {451 ASSERT(m_position != 0);452 m_position = m_position->m_prev;453 return *this;454 }455 456 // postfix ++ intentionally omitted457 458 const_reverse_iterator& operator--()459 {460 ASSERT(m_position != m_set->m_tail);461 if (!m_position)462 m_position = m_set->m_head;463 else464 m_position = m_position->m_next;465 return *this;466 }467 468 // postfix -- intentionally omitted469 470 // Comparison.471 bool operator==(const const_reverse_iterator& other) const472 {473 return m_position == other.m_position;474 }475 bool operator!=(const const_reverse_iterator& other) const476 {477 return m_position != other.m_position;478 }479 480 private:481 Node* node() { return m_position; }482 483 const ListHashSetType* m_set;484 Node* m_position;485 };486 487 383 template<typename ValueType, size_t inlineCapacity, typename HashFunctions> 488 384 struct ListHashSetTranslator { … … 586 482 inline typename ListHashSet<T, inlineCapacity, U>::reverse_iterator ListHashSet<T, inlineCapacity, U>::rbegin() 587 483 { 588 return makeReverseIterator(m_tail);484 return reverse_iterator(end()); 589 485 } 590 486 … … 592 488 inline typename ListHashSet<T, inlineCapacity, U>::reverse_iterator ListHashSet<T, inlineCapacity, U>::rend() 593 489 { 594 return makeReverseIterator(0);490 return reverse_iterator(begin()); 595 491 } 596 492 … … 598 494 inline typename ListHashSet<T, inlineCapacity, U>::const_reverse_iterator ListHashSet<T, inlineCapacity, U>::rbegin() const 599 495 { 600 return makeConstReverseIterator(m_tail);496 return const_reverse_iterator(end()); 601 497 } 602 498 … … 604 500 inline typename ListHashSet<T, inlineCapacity, U>::const_reverse_iterator ListHashSet<T, inlineCapacity, U>::rend() const 605 501 { 606 return makeConstReverseIterator(0);502 return const_reverse_iterator(begin()); 607 503 } 608 504 … … 826 722 827 723 template<typename T, size_t inlineCapacity, typename U> 828 inline ListHashSetReverseIterator<T, inlineCapacity, U> ListHashSet<T, inlineCapacity, U>::makeReverseIterator(Node* position)829 {830 return ListHashSetReverseIterator<T, inlineCapacity, U>(this, position);831 }832 833 template<typename T, size_t inlineCapacity, typename U>834 inline ListHashSetConstReverseIterator<T, inlineCapacity, U> ListHashSet<T, inlineCapacity, U>::makeConstReverseIterator(Node* position) const835 {836 return ListHashSetConstReverseIterator<T, inlineCapacity, U>(this, position);837 }838 839 template<typename T, size_t inlineCapacity, typename U>840 724 inline ListHashSetIterator<T, inlineCapacity, U> ListHashSet<T, inlineCapacity, U>::makeIterator(Node* position) 841 725 {
Note:
See TracChangeset
for help on using the changeset viewer.