diff --git a/BaseLib/quicksort.h b/BaseLib/quicksort.h index aed83fd662437272f1cb0497492646deeb4bf200..d7c74a165376dcbfce8fea8b5f91c44c46d02509 100644 --- a/BaseLib/quicksort.h +++ b/BaseLib/quicksort.h @@ -17,7 +17,6 @@ #include <cstddef> // Base -#include "swap.h" namespace BaseLib { @@ -33,10 +32,10 @@ unsigned partition_(T* array, unsigned beg, unsigned end) while ((j>beg) && !(array[j] < m)) j--; if (i >= j) break; - BaseLib::swap(array[i], array[j]); + std::swap(array[i], array[j]); } - BaseLib::swap(array[beg], array[j]); + std::swap(array[beg], array[j]); return j; } @@ -76,12 +75,12 @@ std::size_t partition_(T1* array, std::size_t beg, std::size_t end, T2 *second_a if (i >= j) break; - BaseLib::swap(array[i], array[j]); - BaseLib::swap(second_array[i], second_array[j]); + std::swap(array[i], array[j]); + std::swap(second_array[i], second_array[j]); } - BaseLib::swap(array[beg], array[j]); - BaseLib::swap(second_array[beg], second_array[j]); + std::swap(array[beg], array[j]); + std::swap(second_array[beg], second_array[j]); return j; } @@ -133,12 +132,12 @@ private: if (i >= j) break; - BaseLib::swap(array[i], array[j]); - BaseLib::swap(perm[i], perm[j]); + std::swap(array[i], array[j]); + std::swap(perm[i], perm[j]); } - BaseLib::swap(array[beg], array[j]); - BaseLib::swap(perm[beg], perm[j]); + std::swap(array[beg], array[j]); + std::swap(perm[beg], perm[j]); return j; } @@ -181,12 +180,12 @@ private: if (i >= j) break; - BaseLib::swap(array[i], array[j]); - BaseLib::swap(perm[i], perm[j]); + std::swap(array[i], array[j]); + std::swap(perm[i], perm[j]); } - BaseLib::swap(array[beg], array[j]); - BaseLib::swap(perm[beg], perm[j]); + std::swap(array[beg], array[j]); + std::swap(perm[beg], perm[j]); return j; } @@ -213,12 +212,12 @@ private: if (i >= j) break; - BaseLib::swap(perm[i], perm[j]); - BaseLib::swap(array[i], array[j]); + std::swap(perm[i], perm[j]); + std::swap(array[i], array[j]); } - BaseLib::swap(perm[beg], perm[j]); - BaseLib::swap(array[beg], array[j]); + std::swap(perm[beg], perm[j]); + std::swap(array[beg], array[j]); return j; } diff --git a/BaseLib/swap.h b/BaseLib/swap.h deleted file mode 100644 index 0dc1bbd27df0821ac134f17bfa7544f915110146..0000000000000000000000000000000000000000 --- a/BaseLib/swap.h +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.org) - * Distributed under a Modified BSD License. - * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * - * - * \file swap.h - * - * Created on xxxx-xx-xx by xx - */ -#ifndef SWAP_H_ -#define SWAP_H_ - -namespace BaseLib { - -/** - * swap the content of arg0 and arg1 - */ -template<class T> void swap(T& arg0, T& arg1) -{ - T temp(arg0); - arg0 = arg1; - arg1 = temp; -} - -} // end namespace BaseLib - -#endif //SWAP_H_ diff --git a/FileIO/MeshIO/GMSHInterface.cpp b/FileIO/MeshIO/GMSHInterface.cpp index 9ab147541f9cb27f0ca948785da8b2f5f4a956a0..f0788fac1abc7cb17deebeb55dbf880760f3e09a 100644 --- a/FileIO/MeshIO/GMSHInterface.cpp +++ b/FileIO/MeshIO/GMSHInterface.cpp @@ -13,7 +13,6 @@ #include <vector> // BaseLib -#include "swap.h" #include "StringTools.h" #include "Configure.h" #include "BuildInfo.h" diff --git a/GeoLib/Polygon.cpp b/GeoLib/Polygon.cpp index fad8c185511703a4f6d4f2b2dd0121e4781fd13b..cbbda7a96bb4c21cc97039cf888b6c17a5a562f1 100644 --- a/GeoLib/Polygon.cpp +++ b/GeoLib/Polygon.cpp @@ -25,7 +25,6 @@ // Base #include "quicksort.h" -#include "swap.h" namespace GeoLib { @@ -304,7 +303,7 @@ void Polygon::ensureCWOrientation () size_t tmp_n_pnts (n_pnts); tmp_n_pnts++; // include last point of polygon (which is identical to the first) for (size_t k(0); k < tmp_n_pnts / 2; k++) - BaseLib::swap (_ply_pnt_ids[k], _ply_pnt_ids[tmp_n_pnts - 1 - k]); + std::swap (_ply_pnt_ids[k], _ply_pnt_ids[tmp_n_pnts - 1 - k]); } for (size_t k(0); k < n_pnts; k++) @@ -329,7 +328,7 @@ void Polygon::splitPolygonAtIntersection (std::list<Polygon*>::iterator polygon_ // split Polygon if (idx0 > idx1) - BaseLib::swap (idx0, idx1); + std::swap (idx0, idx1); GeoLib::Polygon* polygon0 (new GeoLib::Polygon( (*polygon_it)->getPointsVec(), false)); @@ -396,7 +395,7 @@ void Polygon::splitPolygonAtPoint (std::list<GeoLib::Polygon*>::iterator polygon delete [] id_vec; if (idx0 > idx1) - BaseLib::swap (idx0, idx1); + std::swap (idx0, idx1); // create two closed polylines GeoLib::Polygon* polygon0 (new GeoLib::Polygon((*polygon_it)->getPointsVec())); diff --git a/GeoLib/Polyline.cpp b/GeoLib/Polyline.cpp index 188710edf491b23c3d7f722c5b4599dd68781cf5..9f7e0e7b5674090543046d8397174ee3a4742d94 100644 --- a/GeoLib/Polyline.cpp +++ b/GeoLib/Polyline.cpp @@ -10,7 +10,6 @@ */ // Base -#include "swap.h" // GeoLib #include "Polyline.h" @@ -368,14 +367,14 @@ bool containsEdge (const Polyline& ply, size_t id0, size_t id1) return false; } if (id0 > id1) - BaseLib::swap (id0,id1); + std::swap (id0,id1); const size_t n (ply.getNumberOfPoints() - 1); for (size_t k(0); k < n; k++) { size_t ply_pnt0 (ply.getPointID (k)); size_t ply_pnt1 (ply.getPointID (k + 1)); if (ply_pnt0 > ply_pnt1) - BaseLib::swap (ply_pnt0, ply_pnt1); + std::swap (ply_pnt0, ply_pnt1); if (ply_pnt0 == id0 && ply_pnt1 == id1) return true; } diff --git a/MathLib/AnalyticalGeometry.cpp b/MathLib/AnalyticalGeometry.cpp index 150103fa5ed5d05f7ec8ff25ceb71db6ff08a128..2a9e83c387636cc83ca092573ed5ebb9e81f1d06 100644 --- a/MathLib/AnalyticalGeometry.cpp +++ b/MathLib/AnalyticalGeometry.cpp @@ -17,7 +17,6 @@ #include <fstream> // Base -#include "swap.h" #include "quicksort.h" // GEO diff --git a/MathLib/EarClippingTriangulation.cpp b/MathLib/EarClippingTriangulation.cpp index 4d0369a26c2df7eacaa57132225ff53d9cb5a317..27482f4fea633bc0da76cc7a9ce0a08d39baf785 100644 --- a/MathLib/EarClippingTriangulation.cpp +++ b/MathLib/EarClippingTriangulation.cpp @@ -14,7 +14,6 @@ #include <vector> // BaseLib -#include "swap.h" #include "printList.h" #include "uniqueInsert.h" @@ -124,7 +123,7 @@ void EarClippingTriangulation::ensureCWOrientation () if (_original_orient == MathLib::CCW) { // switch orientation for (std::size_t k(0); k<n_pnts/2; k++) { - BaseLib::swap (_pnts[k], _pnts[n_pnts-1-k]); + std::swap (_pnts[k], _pnts[n_pnts-1-k]); } } } diff --git a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp index 4374c0f4b928244c84bdb3c1ee78be85b3bc1648..7b76b21cf3462e8f81e75c2b779d109d8f862bdf 100644 --- a/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp +++ b/MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.cpp @@ -12,7 +12,6 @@ #include "PiecewiseLinearInterpolation.h" #include "binarySearch.h" -#include "swap.h" #include <iostream> diff --git a/MathLib/LinAlg/Solvers/GaussAlgorithm.cpp b/MathLib/LinAlg/Solvers/GaussAlgorithm.cpp index 461ca920c61463203612adeeec5efff51b3518c8..eb3ea309c62437e91130daee8bb9c3d26a30d3eb 100644 --- a/MathLib/LinAlg/Solvers/GaussAlgorithm.cpp +++ b/MathLib/LinAlg/Solvers/GaussAlgorithm.cpp @@ -12,7 +12,6 @@ #include <cmath> #include "GaussAlgorithm.h" -#include "swap.h" namespace MathLib { @@ -35,7 +34,7 @@ GaussAlgorithm::GaussAlgorithm (Matrix <double> &A) : // exchange rows if (_perm[k] != k) { - for (j=0; j<nc; j++) BaseLib::swap (_mat(_perm[k],j), _mat(k,j)); + for (j=0; j<nc; j++) std::swap (_mat(_perm[k],j), _mat(k,j)); } // eliminate @@ -64,7 +63,7 @@ void GaussAlgorithm::execute (double *b) const void GaussAlgorithm::permuteRHS (double* b) const { for (size_t i=0; i<_n; i++) { - if (_perm[i] != i) BaseLib::swap(b[i], b[_perm[i]]); + if (_perm[i] != i) std::swap(b[i], b[_perm[i]]); } } diff --git a/MathLib/LinAlg/Sparse/CRSMatrix.h b/MathLib/LinAlg/Sparse/CRSMatrix.h index e40b46d6f35f0323be7a92937006ba9bc0c69a18..872adaea451729e0f1de27c0ee8994db93364d57 100644 --- a/MathLib/LinAlg/Sparse/CRSMatrix.h +++ b/MathLib/LinAlg/Sparse/CRSMatrix.h @@ -19,7 +19,6 @@ #include <cassert> // Base -#include "swap.h" // MathLib #include "SparseMatrixBase.h" @@ -333,9 +332,9 @@ protected: } MatrixBase::_n_rows -= n_rows_cols; - BaseLib::swap (row_ptr_new, _row_ptr); - BaseLib::swap (col_idx_new, _col_idx); - BaseLib::swap (data_new, _data); + std::swap (row_ptr_new, _row_ptr); + std::swap (col_idx_new, _col_idx); + std::swap (data_new, _data); delete [] row_ptr_new_tmp; delete [] row_ptr_new; @@ -385,10 +384,10 @@ protected: } } - BaseLib::swap(MatrixBase::_n_rows, MatrixBase::_n_cols); - BaseLib::swap(row_ptr_trans, _row_ptr); - BaseLib::swap(col_idx_trans, _col_idx); - BaseLib::swap(data_trans, _data); + std::swap(MatrixBase::_n_rows, MatrixBase::_n_cols); + std::swap(row_ptr_trans, _row_ptr); + std::swap(col_idx_trans, _col_idx); + std::swap(data_trans, _data); delete[] row_ptr_nnz; delete[] row_ptr_trans; diff --git a/MathLib/LinAlg/Sparse/NestedDissectionPermutation/AdjMat.cpp b/MathLib/LinAlg/Sparse/NestedDissectionPermutation/AdjMat.cpp index 849ea3384c7e3d61bfa72bd4f6c5d9739294248e..87ae7e5c3252ab4ba11a7ce2ebdd2662dbd354ea 100644 --- a/MathLib/LinAlg/Sparse/NestedDissectionPermutation/AdjMat.cpp +++ b/MathLib/LinAlg/Sparse/NestedDissectionPermutation/AdjMat.cpp @@ -11,7 +11,6 @@ */ // Base -#include "swap.h" #include "quicksort.h" #include "LinAlg/Sparse/NestedDissectionPermutation/AdjMat.h" @@ -142,8 +141,8 @@ void genAdjMat(unsigned n, unsigned* &iA, unsigned* &jA) if (i < jA[k]) jAn[con[i]++] = jA[k]; - BaseLib::swap(jA, jAn); - BaseLib::swap(iA, iAn); + std::swap(jA, jAn); + std::swap(iA, iAn); delete[] jAn; delete[] con; @@ -189,8 +188,8 @@ void genFullAdjMat(unsigned n, unsigned* &iA, unsigned* &jA) } } - BaseLib::swap(jA, jAn); - BaseLib::swap(iA, iAn); + std::swap(jA, jAn); + std::swap(iA, iAn); delete[] jAn; delete[] iAn; diff --git a/MathLib/LinAlg/Sparse/NestedDissectionPermutation/CRSMatrixReordered.cpp b/MathLib/LinAlg/Sparse/NestedDissectionPermutation/CRSMatrixReordered.cpp index e147ac155d70653e1a6d6facbc0c5b3cdbfbac79..ed13a75c044d48290d8a24dda2aa87013bbfeb10 100644 --- a/MathLib/LinAlg/Sparse/NestedDissectionPermutation/CRSMatrixReordered.cpp +++ b/MathLib/LinAlg/Sparse/NestedDissectionPermutation/CRSMatrixReordered.cpp @@ -64,9 +64,9 @@ void CRSMatrixReordered::reorderMatrix(unsigned const*const op_perm, unsigned co for (i = 0; i < size; ++i) BaseLib::quicksort(jAn, static_cast<size_t>(iAn[i]), static_cast<size_t>(iAn[i + 1]), An); - BaseLib::swap(iAn, _row_ptr); - BaseLib::swap(jAn, _col_idx); - BaseLib::swap(An, _data); + std::swap(iAn, _row_ptr); + std::swap(jAn, _col_idx); + std::swap(An, _data); delete [] iAn; delete [] jAn; diff --git a/MathLib/LinAlg/Sparse/NestedDissectionPermutation/Cluster.cpp b/MathLib/LinAlg/Sparse/NestedDissectionPermutation/Cluster.cpp index cd6bc82442c77884a4290579bcb15c7280e4e6d7..e4c1f480f7207a49b521b6cd03fd2d2cab731f9c 100644 --- a/MathLib/LinAlg/Sparse/NestedDissectionPermutation/Cluster.cpp +++ b/MathLib/LinAlg/Sparse/NestedDissectionPermutation/Cluster.cpp @@ -13,7 +13,6 @@ #include "metis.h" // BaseLib -#include "swap.h" #include "LinAlg/Sparse/NestedDissectionPermutation/Cluster.h" //#include "blas.h" @@ -162,9 +161,9 @@ void Cluster::updatePerm(unsigned* reordering, unsigned &isep0, while (beg < end && reordering[end] >= 1) --end; // local permutation - BaseLib::swap(l_op_perm[beg], l_op_perm[end]); - BaseLib::swap(l_po_perm[l_op_perm[beg]], l_po_perm[l_op_perm[end]]); - BaseLib::swap(reordering[beg], reordering[end]); + std::swap(l_op_perm[beg], l_op_perm[end]); + std::swap(l_po_perm[l_op_perm[beg]], l_po_perm[l_op_perm[end]]); + std::swap(reordering[beg], reordering[end]); } ++beg; } @@ -180,9 +179,9 @@ void Cluster::updatePerm(unsigned* reordering, unsigned &isep0, while (beg < end && reordering[end] == 2) --end; // local permutation - BaseLib::swap(l_op_perm[beg], l_op_perm[end]); - BaseLib::swap(l_po_perm[l_op_perm[beg]], l_po_perm[l_op_perm[end]]); - BaseLib::swap(reordering[beg], reordering[end]); + std::swap(l_op_perm[beg], l_op_perm[end]); + std::swap(l_po_perm[l_op_perm[beg]], l_po_perm[l_op_perm[end]]); + std::swap(reordering[beg], reordering[end]); } ++beg; } diff --git a/MathLib/LinAlg/Sparse/NestedDissectionPermutation/Separator.cpp b/MathLib/LinAlg/Sparse/NestedDissectionPermutation/Separator.cpp index fd5f31beb5c15ac59b1589763be8f6fd26f6ac76..f65c1aa6815ecbb5d3740fb29572e523487b4097 100644 --- a/MathLib/LinAlg/Sparse/NestedDissectionPermutation/Separator.cpp +++ b/MathLib/LinAlg/Sparse/NestedDissectionPermutation/Separator.cpp @@ -11,7 +11,6 @@ */ // BaseLib -#include "swap.h" #include "LinAlg/Sparse/NestedDissectionPermutation/Separator.h" @@ -39,8 +38,8 @@ unsigned Separator::updatePerm(unsigned* reordering, unsigned* l_op_perm, unsign --end; while (beg < end && reordering[end] == 1) --end; // local permutation - BaseLib::swap(l_op_perm [beg], l_op_perm[end]); - BaseLib::swap(l_po_perm[l_op_perm [beg]], l_po_perm[l_op_perm[end]]); + std::swap(l_op_perm [beg], l_op_perm[end]); + std::swap(l_po_perm[l_op_perm [beg]], l_po_perm[l_op_perm[end]]); } ++beg; } diff --git a/Tests/BaseLib/TestSwap.cpp b/Tests/BaseLib/TestSwap.cpp index c5094b4627e6a7e8bf78203d6bf6d932f232a4b3..2265a30a11f556eaaec0ee53356dcee6362500e5 100644 --- a/Tests/BaseLib/TestSwap.cpp +++ b/Tests/BaseLib/TestSwap.cpp @@ -12,12 +12,10 @@ // ** INCLUDES ** #include "gtest.h" -#include "swap.h" - TEST(BaseLib, SwapInt) { int arg0 = 5; int arg1 = 10; - BaseLib::swap(arg0, arg1); + std::swap(arg0, arg1); ASSERT_EQ ( arg0, 10 ); ASSERT_EQ ( arg1, 5 ); } @@ -25,7 +23,7 @@ TEST(BaseLib, SwapInt) { TEST(BaseLib, SwapDouble) { double arg0 = 5.0; double arg1 = 10.0; - BaseLib::swap(arg0, arg1); + std::swap(arg0, arg1); ASSERT_EQ ( arg0, 10.0 ); ASSERT_EQ ( arg1, 5.0 ); } @@ -33,7 +31,7 @@ TEST(BaseLib, SwapDouble) { TEST(BaseLib, SwapString) { std::string arg0 = "5"; std::string arg1 = "10"; - BaseLib::swap(arg0, arg1); + std::swap(arg0, arg1); ASSERT_EQ ( arg0, std::string("10") ); ASSERT_EQ ( arg1, std::string("5") ); }