Skip to content
Snippets Groups Projects
Commit 1a976d3c authored by Tom Fischer's avatar Tom Fischer
Browse files

moved code to namespace BaseLib in files:

- FileFinder.h
- FileTools.h
- TimeMeasurementBase.h
- quicksort.h

changes due to namespace changes in:
- PointVec.cpp
- Polygon.cpp
- AdjMat.cpp
- CRSMatrixReordered.cpp
parent 1bb34cdb
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#ifndef FILEFINDER_H #ifndef FILEFINDER_H
#define FILEFINDER_H #define FILEFINDER_H
namespace BaseLib {
/** /**
* FileFinder stores a list of directories and will return the complete path * FileFinder stores a list of directories and will return the complete path
* for a given filename if the corresponding file is found in any of these * for a given filename if the corresponding file is found in any of these
...@@ -46,9 +47,9 @@ public: ...@@ -46,9 +47,9 @@ public:
}; };
private: private:
std::list<std::string> _directories; std::list<std::string> _directories;
};
} // end namespace BaseLib
};
#endif // FILEFINDER_H #endif // FILEFINDER_H
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
// ** INCLUDES ** // ** INCLUDES **
#include <sys/stat.h> #include <sys/stat.h>
namespace BaseLib {
/** /**
* Returns true if given file exists. From http://www.techbytes.ca/techbyte103.html * Returns true if given file exists. From http://www.techbytes.ca/techbyte103.html
*/ */
...@@ -43,4 +44,6 @@ static bool IsFileExisting(std::string strFilename) ...@@ -43,4 +44,6 @@ static bool IsFileExisting(std::string strFilename)
return(blnReturn); return(blnReturn);
} }
} // end namespace BaseLib
#endif // FILETOOLS_H #endif // FILETOOLS_H
#ifndef TIMEMEASUREMENT_H #ifndef TIMEMEASUREMENT_H
#define TIMEMEASUREMENT_H #define TIMEMEASUREMENT_H
class TimeMeasurementBase namespace BaseLib {
class TimeMeasurementBase
{ {
public: public:
virtual void start () = 0; virtual void start () = 0;
...@@ -10,5 +12,6 @@ public: ...@@ -10,5 +12,6 @@ public:
virtual ~TimeMeasurementBase () {}; virtual ~TimeMeasurementBase () {};
}; };
#endif } // end namespace BaseLib
#endif
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
// Base // Base
#include "swap.h" #include "swap.h"
namespace BaseLib {
template <class T> template <class T>
unsigned partition_(T* array, unsigned beg, unsigned end) unsigned partition_(T* array, unsigned beg, unsigned end)
{ {
...@@ -97,9 +99,13 @@ void quicksort(T1* array, size_t beg, size_t end, T2* second_array) ...@@ -97,9 +99,13 @@ void quicksort(T1* array, size_t beg, size_t end, T2* second_array)
} }
} }
} // end namespace BaseLib
// STL // STL
#include <vector> #include <vector>
namespace BaseLib {
template <typename T> template <typename T>
class Quicksort { class Quicksort {
public: public:
...@@ -219,7 +225,8 @@ private: ...@@ -219,7 +225,8 @@ private:
quicksort(perm, p+1, end, array); quicksort(perm, p+1, end, array);
} }
} }
}; };
} // end namespace BaseLib
#endif /* QUICKSORT_H_ */ #endif /* QUICKSORT_H_ */
...@@ -156,7 +156,7 @@ void PointVec::makePntsUnique (std::vector<GEOLIB::Point*>* pnt_vec, std::vector ...@@ -156,7 +156,7 @@ void PointVec::makePntsUnique (std::vector<GEOLIB::Point*>* pnt_vec, std::vector
} }
// sort the points // sort the points
Quicksort<GEOLIB::Point*> (*pnt_vec, 0, n_pnts_in_file, perm); BaseLib::Quicksort<GEOLIB::Point*> (*pnt_vec, 0, n_pnts_in_file, perm);
// unfortunately quicksort is not stable - // unfortunately quicksort is not stable -
// sort identical points by id - to make sorting stable // sort identical points by id - to make sorting stable
...@@ -199,7 +199,7 @@ void PointVec::makePntsUnique (std::vector<GEOLIB::Point*>* pnt_vec, std::vector ...@@ -199,7 +199,7 @@ void PointVec::makePntsUnique (std::vector<GEOLIB::Point*>* pnt_vec, std::vector
} }
// reverse permutation // reverse permutation
Quicksort<GEOLIB::Point*> (perm, 0, n_pnts_in_file, *pnt_vec); BaseLib::Quicksort<GEOLIB::Point*> (perm, 0, n_pnts_in_file, *pnt_vec);
// remove the second, third, ... occurrence from vector // remove the second, third, ... occurrence from vector
for (size_t k(0); k<n_pnts_in_file; k++) { for (size_t k(0); k<n_pnts_in_file; k++) {
......
...@@ -334,7 +334,7 @@ void Polygon::splitPolygonAtPoint (std::list<GEOLIB::Polygon*>::iterator polygon ...@@ -334,7 +334,7 @@ void Polygon::splitPolygonAtPoint (std::list<GEOLIB::Polygon*>::iterator polygon
perm[k] = k; perm[k] = k;
} }
quicksort (id_vec, 0, n, perm); BaseLib::quicksort (id_vec, 0, n, perm);
for (size_t k(0); k<n-1; k++) { for (size_t k(0); k<n-1; k++) {
if (id_vec[k] == id_vec[k+1]) { if (id_vec[k] == id_vec[k+1]) {
......
...@@ -55,7 +55,7 @@ AdjMat* AdjMat::getMat(unsigned beg, unsigned end, ...@@ -55,7 +55,7 @@ AdjMat* AdjMat::getMat(unsigned beg, unsigned end,
delete[] pos; delete[] pos;
for (i = 0; i < nsize; ++i) for (i = 0; i < nsize; ++i)
quickSort(jAn, iAn[i], iAn[i + 1]); BaseLib::quickSort(jAn, iAn[i], iAn[i + 1]);
return new AdjMat(nsize, iAn, jAn, NULL); return new AdjMat(nsize, iAn, jAn, NULL);
} }
......
...@@ -57,7 +57,7 @@ void CRSMatrixReordered::reorderMatrix(unsigned const*const op_perm, unsigned co ...@@ -57,7 +57,7 @@ void CRSMatrixReordered::reorderMatrix(unsigned const*const op_perm, unsigned co
delete[] pos; delete[] pos;
for (i = 0; i < size; ++i) for (i = 0; i < size; ++i)
quicksort(jAn, static_cast<size_t>(iAn[i]), static_cast<size_t>(iAn[i + 1]), An); BaseLib::quicksort(jAn, static_cast<size_t>(iAn[i]), static_cast<size_t>(iAn[i + 1]), An);
BaseLib::swap(iAn, _row_ptr); BaseLib::swap(iAn, _row_ptr);
BaseLib::swap(jAn, _col_idx); BaseLib::swap(jAn, _col_idx);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment