| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com> | 3 * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com> |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 { | 492 { |
| 493 LinkedHashSet tmp(other); | 493 LinkedHashSet tmp(other); |
| 494 swap(tmp); | 494 swap(tmp); |
| 495 return *this; | 495 return *this; |
| 496 } | 496 } |
| 497 | 497 |
| 498 template<typename T, typename U, typename V, typename W> | 498 template<typename T, typename U, typename V, typename W> |
| 499 inline void LinkedHashSet<T, U, V, W>::swap(LinkedHashSet& other) | 499 inline void LinkedHashSet<T, U, V, W>::swap(LinkedHashSet& other) |
| 500 { | 500 { |
| 501 m_impl.swap(other.m_impl); | 501 m_impl.swap(other.m_impl); |
| 502 swap(m_anchor, other.m_anchor); | 502 swapAnchor(m_anchor, other.m_anchor); |
| 503 } | 503 } |
| 504 | 504 |
| 505 template<typename T, typename U, typename V, typename Allocator> | 505 template<typename T, typename U, typename V, typename Allocator> |
| 506 inline LinkedHashSet<T, U, V, Allocator>::~LinkedHashSet() | 506 inline LinkedHashSet<T, U, V, Allocator>::~LinkedHashSet() |
| 507 { | 507 { |
| 508 // The destructor of m_anchor will implicitly be called here, which will | 508 // The destructor of m_anchor will implicitly be called here, which will |
| 509 // unlink the anchor from the collection. | 509 // unlink the anchor from the collection. |
| 510 } | 510 } |
| 511 | 511 |
| 512 template<typename T, typename U, typename V, typename W> | 512 template<typename T, typename U, typename V, typename W> |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 return; | 660 return; |
| 661 m_impl.remove(it.node()); | 661 m_impl.remove(it.node()); |
| 662 } | 662 } |
| 663 | 663 |
| 664 template<typename T, typename U, typename V, typename W> | 664 template<typename T, typename U, typename V, typename W> |
| 665 inline void LinkedHashSet<T, U, V, W>::remove(ValuePeekInType value) | 665 inline void LinkedHashSet<T, U, V, W>::remove(ValuePeekInType value) |
| 666 { | 666 { |
| 667 remove(find(value)); | 667 remove(find(value)); |
| 668 } | 668 } |
| 669 | 669 |
| 670 inline void swapAnchor(LinkedHashSetNodeBase& a, LinkedHashSetNodeBase& b) |
| 671 { |
| 672 ASSERT(a.m_prev && a.m_next && b.m_prev && b.m_next); |
| 673 swap(a.m_prev, b.m_prev); |
| 674 swap(a.m_next, b.m_next); |
| 675 if (b.m_next == &a) { |
| 676 ASSERT(b.m_prev == &a); |
| 677 b.m_next = &b; |
| 678 b.m_prev = &b; |
| 679 } else { |
| 680 b.m_next->m_prev = &b; |
| 681 b.m_prev->m_next = &b; |
| 682 } |
| 683 if (a.m_next == &b) { |
| 684 ASSERT(a.m_prev == &b); |
| 685 a.m_next = &a; |
| 686 a.m_prev = &a; |
| 687 } else { |
| 688 a.m_next->m_prev = &a; |
| 689 a.m_prev->m_next = &a; |
| 690 } |
| 691 } |
| 692 |
| 670 inline void swap(LinkedHashSetNodeBase& a, LinkedHashSetNodeBase& b) | 693 inline void swap(LinkedHashSetNodeBase& a, LinkedHashSetNodeBase& b) |
| 671 { | 694 { |
| 695 ASSERT(a.m_next != &a && b.m_next != &b); |
| 672 swap(a.m_prev, b.m_prev); | 696 swap(a.m_prev, b.m_prev); |
| 673 swap(a.m_next, b.m_next); | 697 swap(a.m_next, b.m_next); |
| 674 if (b.m_next) { | 698 if (b.m_next) { |
| 675 b.m_next->m_prev = &b; | 699 b.m_next->m_prev = &b; |
| 676 b.m_prev->m_next = &b; | 700 b.m_prev->m_next = &b; |
| 677 } | 701 } |
| 678 if (a.m_next) { | 702 if (a.m_next) { |
| 679 a.m_next->m_prev = &a; | 703 a.m_next->m_prev = &a; |
| 680 a.m_prev->m_next = &a; | 704 a.m_prev->m_next = &a; |
| 681 } | 705 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 707 struct NeedsTracing<LinkedHashSet<T, U, V> > { | 731 struct NeedsTracing<LinkedHashSet<T, U, V> > { |
| 708 static const bool value = false; | 732 static const bool value = false; |
| 709 }; | 733 }; |
| 710 #endif | 734 #endif |
| 711 | 735 |
| 712 } | 736 } |
| 713 | 737 |
| 714 using WTF::LinkedHashSet; | 738 using WTF::LinkedHashSet; |
| 715 | 739 |
| 716 #endif /* WTF_LinkedHashSet_h */ | 740 #endif /* WTF_LinkedHashSet_h */ |
| OLD | NEW |