summaryrefslogtreecommitdiff
path: root/shared/global_func.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:14:37 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:14:37 +0200
commit8bf668665b107469086f16cb8ad23e47d479d2b4 (patch)
tree66a91ef06a8caa7cd6819dcbe1860693d3eda8d5 /shared/global_func.h
parent3.21 (diff)
downloadFreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.gz
FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.tar.bz2
FreeFileSync-8bf668665b107469086f16cb8ad23e47d479d2b4.zip
4.0
Diffstat (limited to 'shared/global_func.h')
-rw-r--r--shared/global_func.h99
1 files changed, 7 insertions, 92 deletions
diff --git a/shared/global_func.h b/shared/global_func.h
index 861e2081..b3c13a24 100644
--- a/shared/global_func.h
+++ b/shared/global_func.h
@@ -7,106 +7,21 @@
#ifndef GLOBALFUNCTIONS_H_INCLUDED
#define GLOBALFUNCTIONS_H_INCLUDED
-#include <string>
-#include <algorithm>
-#include <vector>
-#include <set>
-#include <wx/string.h>
+#include <cmath>
namespace common
{
//little rounding function
-inline int round(double d) { return static_cast<int>(d < 0 ? d - 0.5 : d + 0.5); }
-
-//absolute value
-template <class T> inline T abs(const T& d) { return d < 0 ? -d : d; }
-
-size_t getDigitCount(size_t number); //count number of digits
-
-//Note: the following lines are a performance optimization for deleting elements from a vector: linear runtime at most!
-template <class T>
-void removeRowsFromVector(const std::set<size_t>& rowsToRemove, std::vector<T>& grid);
-
-//enhanced binary search template: returns an iterator
-template <class ForwardIterator, class T, typename Compare>
-ForwardIterator custom_binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp = std::less<T>());
-}
-
-
-//############################################################################
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-//---------------Inline Implementation---------------------------------------------------
inline
-size_t common::getDigitCount(size_t number) //count number of digits
-{
- return number == 0 ? 1 : static_cast<size_t>(::log10(static_cast<double>(number))) + 1;
-}
-
-
-//Note: the following lines are a performance optimization for deleting elements from a vector: linear runtime at most!
-template <class T>
-void common::removeRowsFromVector(const std::set<size_t>& rowsToRemove, std::vector<T>& grid)
-{
- if (rowsToRemove.empty())
- return;
-
- std::set<size_t>::const_iterator rowToSkipIndex = rowsToRemove.begin();
- size_t rowToSkip = *rowToSkipIndex;
-
- if (rowToSkip >= grid.size())
- return;
-
- typename std::vector<T>::iterator insertPos = grid.begin() + rowToSkip;
-
- for (size_t i = rowToSkip; i < grid.size(); ++i)
- {
- if (i != rowToSkip)
- {
- *insertPos = grid[i];
- ++insertPos;
- }
- else
- {
- ++rowToSkipIndex;
- if (rowToSkipIndex != rowsToRemove.end())
- rowToSkip = *rowToSkipIndex;
- }
- }
- grid.erase(insertPos, grid.end());
-}
+int round(double d) { return static_cast<int>(d < 0 ? d - 0.5 : d + 0.5); }
+//absolute value
+template <class T> inline
+T abs(const T& d) { return d < 0 ? -d : d; }
-//enhanced binary search template: returns an iterator
-template <class ForwardIterator, class T, typename Compare>
inline
-ForwardIterator common::custom_binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp)
-{
- first = std::lower_bound(first, last, value, comp);
- if (first != last && !comp(value, *first))
- return first;
- else
- return last;
+size_t getDigitCount(size_t number) { return number == 0 ? 1 : static_cast<size_t>(std::log10(static_cast<double>(number))) + 1; } //count number of digits
}
-#endif // GLOBALFUNCTIONS_H_INCLUDED
+#endif //GLOBALFUNCTIONS_H_INCLUDED
bgstack15