Ticket #2810: list.hpp.patch
File list.hpp.patch, 1.5 KB (added by , 14 years ago) |
---|
-
list.hpp
1021 1023 template<class Predicate> 1022 1024 void merge(list_impl& x, Predicate p) 1023 1025 { 1024 const_iterator e(this->end()); 1025 const_iterator bx(x.begin()); 1026 const_iterator ex(x.end()); 1026 const_iterator b = this->cbegin(), e = this->cend(); 1027 const_iterator ex = x.cend(); 1027 1028 1028 for (const_iterator b = this->cbegin(); b != e; ++b) { 1029 size_type n(0); 1030 const_iterator ix(bx); 1031 while(ix != ex && p(*ix, *b)){ 1032 ++ix; ++n; 1029 while (!x.empty()) 1030 { 1031 const_iterator bx = x.cbegin(); 1032 while (b != e && p(*bx, *b)) 1033 { 1034 ++b; 1033 1035 } 1034 this->splice(b, x, bx, ix, n); 1035 bx = ix; 1036 1037 if (b != e) 1038 { 1039 // determine the end of the range of x to inject at b 1040 size_type n = 0; 1041 do 1042 { 1043 ++bx; 1044 ++n; 1045 } 1046 while (bx != ex && p(*bx, *b)); 1047 this->splice(b, x, x.cbegin(), bx, n); 1048 } 1049 else 1050 { 1051 // the rest of the list is to be appended to the end 1052 this->splice(e, x); 1053 break; 1054 } 1036 1055 } 1037 //Now transfer the rest at the end of the container1038 this->splice(e, x);1039 1056 } 1040 1057 1041 1058 //! <b>Effects</b>: Reverses the order of elements in the list.