完成swap
This commit is contained in:
@@ -132,7 +132,7 @@ namespace TinySTL{
|
|||||||
void insert(iterator position, InputIterator first, InputIterator last);
|
void insert(iterator position, InputIterator first, InputIterator last);
|
||||||
iterator erase(iterator position);
|
iterator erase(iterator position);
|
||||||
iterator erase(iterator first, iterator last);
|
iterator erase(iterator first, iterator last);
|
||||||
//void swap(List& x);
|
void swap(List& x);
|
||||||
void clear();
|
void clear();
|
||||||
//void splice(iterator position, list& x);
|
//void splice(iterator position, list& x);
|
||||||
//void splice(iterator position, list& x, iterator i);
|
//void splice(iterator position, list& x, iterator i);
|
||||||
@@ -175,6 +175,9 @@ namespace TinySTL{
|
|||||||
insert(position, *first);
|
insert(position, *first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public:
|
||||||
|
template<class T>
|
||||||
|
friend void swap(List<T>& x, List<T>& y);
|
||||||
};
|
};
|
||||||
template<class T>
|
template<class T>
|
||||||
void List<T>::push_front(const value_type& val){
|
void List<T>::push_front(const value_type& val){
|
||||||
@@ -284,6 +287,15 @@ namespace TinySTL{
|
|||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
template<class T>
|
||||||
|
void List<T>::swap(List& x){
|
||||||
|
TinySTL::swap(head.p, x.head.p);
|
||||||
|
TinySTL::swap(tail.p, x.tail.p);
|
||||||
|
}
|
||||||
|
template<class T>
|
||||||
|
void swap(List<T>& x, List<T>& y){
|
||||||
|
x.swap(y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user