optimize piSwap and c++11 improvments
This commit is contained in:
@@ -538,5 +538,7 @@ inline PICout operator <<(PICout s, const PIDeque<T> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename T> inline void piSwap(PIDeque<T> & f, PIDeque<T> & s) {f.swap(s);}
|
||||
|
||||
|
||||
#endif // PIDEQUE_H
|
||||
|
||||
@@ -57,7 +57,7 @@ void piQuickSort(T * a, ssize_t N) {
|
||||
if (i <= j) {
|
||||
if (i != j) {
|
||||
//piCout << "swap" << i << j << a[i] << a[j];
|
||||
piSwapBinary<T>(a[i], a[j]);
|
||||
piSwap<T>(a[i], a[j]);
|
||||
}
|
||||
i++; j--;
|
||||
}
|
||||
@@ -216,8 +216,8 @@ public:
|
||||
PIMap<Key, T> & clear() {pim_content.clear(); pim_index.clear(); return *this;}
|
||||
|
||||
void swap(PIMap<Key, T> & other) {
|
||||
piSwapBinary<PIVector<T> >(pim_content, other.pim_content);
|
||||
piSwapBinary<PIDeque<MapIndex> >(pim_index, other.pim_index);
|
||||
pim_content.swap(other.pim_content);
|
||||
pim_index.swap(other.pim_index);
|
||||
}
|
||||
|
||||
PIMap<Key, T> & insert(const Key & key, const T & value) {
|
||||
@@ -292,7 +292,7 @@ protected:
|
||||
pim_index[i].index = ci;
|
||||
break;
|
||||
}
|
||||
piSwapBinary<T>(pim_content[ci], pim_content.back());
|
||||
piSwap<T>(pim_content[ci], pim_content.back());
|
||||
pim_content.resize(pim_index.size());
|
||||
}
|
||||
const value_type _pair(ssize_t index) const {
|
||||
@@ -342,5 +342,7 @@ inline PICout operator <<(PICout s, const PIMap<Key, Type> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename Key, typename Type> inline void piSwap(PIMap<Key, Type> & f, PIMap<Key, Type> & s) {f.swap(s);}
|
||||
|
||||
|
||||
#endif // PIMAP_H
|
||||
|
||||
@@ -487,5 +487,7 @@ inline PICout operator <<(PICout s, const PIVector<T> & v) {
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename T> inline void piSwap(PIVector<T> & f, PIVector<T> & s) {f.swap(s);}
|
||||
|
||||
|
||||
#endif // PIVECTOR_H
|
||||
|
||||
Reference in New Issue
Block a user