Changeset 96741 in webkit for trunk/Source/JavaScriptCore/wtf
- Timestamp:
- Oct 5, 2011, 1:01:32 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/wtf/ListHashSet.h
r96733 r96741 28 28 #include "PassOwnPtr.h" 29 29 #include "StdLibExtras.h" 30 #include <iterator>31 30 32 31 namespace WTF { … … 51 50 template<typename ValueArg, size_t inlineCapacity, typename HashArg> class ListHashSetIterator; 52 51 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; 53 54 54 55 template<typename ValueArg, size_t inlineCapacity> struct ListHashSetNode; … … 78 79 friend class ListHashSetConstIterator<ValueType, inlineCapacity, HashArg>; 79 80 80 typedef std::reverse_iterator<iterator> reverse_iterator; 81 typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 81 typedef ListHashSetReverseIterator<ValueType, inlineCapacity, HashArg> reverse_iterator; 82 typedef ListHashSetConstReverseIterator<ValueType, inlineCapacity, HashArg> const_reverse_iterator; 83 friend class ListHashSetConstReverseIterator<ValueType, inlineCapacity, HashArg>; 82 84 83 85 ListHashSet(); … … 139 141 iterator makeIterator(Node*); 140 142 const_iterator makeConstIterator(Node*) const; 143 reverse_iterator makeReverseIterator(Node*); 144 const_reverse_iterator makeConstReverseIterator(Node*) const; 141 145 142 146 friend void deleteAllValues<>(const ListHashSet&); … … 268 272 269 273 friend class ListHashSet<ValueArg, inlineCapacity, HashArg>; 270 274 271 275 ListHashSetIterator(const ListHashSetType* set, Node* position) : m_iterator(set, position) { } 272 276 273 277 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 280 278 ListHashSetIterator() { } 281 279 … … 326 324 327 325 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 334 326 ListHashSetConstIterator() 335 327 { … … 381 373 }; 382 374 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 OK 393 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 omitted 401 402 reverse_iterator& operator--() { --m_iterator; return *this; } 403 404 // postfix -- intentionally omitted 405 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() const 443 { 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 omitted 457 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 else 464 m_position = m_position->m_next; 465 return *this; 466 } 467 468 // postfix -- intentionally omitted 469 470 // Comparison. 471 bool operator==(const const_reverse_iterator& other) const 472 { 473 return m_position == other.m_position; 474 } 475 bool operator!=(const const_reverse_iterator& other) const 476 { 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 383 487 template<typename ValueType, size_t inlineCapacity, typename HashFunctions> 384 488 struct ListHashSetTranslator { … … 482 586 inline typename ListHashSet<T, inlineCapacity, U>::reverse_iterator ListHashSet<T, inlineCapacity, U>::rbegin() 483 587 { 484 return reverse_iterator(end());588 return makeReverseIterator(m_tail); 485 589 } 486 590 … … 488 592 inline typename ListHashSet<T, inlineCapacity, U>::reverse_iterator ListHashSet<T, inlineCapacity, U>::rend() 489 593 { 490 return reverse_iterator(begin());594 return makeReverseIterator(0); 491 595 } 492 596 … … 494 598 inline typename ListHashSet<T, inlineCapacity, U>::const_reverse_iterator ListHashSet<T, inlineCapacity, U>::rbegin() const 495 599 { 496 return const_reverse_iterator(end());600 return makeConstReverseIterator(m_tail); 497 601 } 498 602 … … 500 604 inline typename ListHashSet<T, inlineCapacity, U>::const_reverse_iterator ListHashSet<T, inlineCapacity, U>::rend() const 501 605 { 502 return const_reverse_iterator(begin());606 return makeConstReverseIterator(0); 503 607 } 504 608 … … 722 826 723 827 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) const 835 { 836 return ListHashSetConstReverseIterator<T, inlineCapacity, U>(this, position); 837 } 838 839 template<typename T, size_t inlineCapacity, typename U> 724 840 inline ListHashSetIterator<T, inlineCapacity, U> ListHashSet<T, inlineCapacity, U>::makeIterator(Node* position) 725 841 {
Note:
See TracChangeset
for help on using the changeset viewer.