-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutility.h
42 lines (35 loc) · 1.09 KB
/
utility.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* utility.h
*
* Created on: May 18, 2015
* Author: trungvv1
*/
#ifndef UTILITY_H_
#define UTILITY_H_
#include <string>
#include <vector>
#include <sstream>
using namespace std;
template <typename T>
struct PtrLess // public std::binary_function<bool, const T*, const T*>
{
bool operator()(const T* a, const T* b) const
{
// may want to check that the pointers aren't zero...
return *a < *b;
}
};
class Utility {
public:
/// io utils
static vector<vector<double>> readTsvData(const string & filename);
static vector<vector<uint>> readTsvUintData(const string & filename);
static void writeTsvData(const string & filename, const vector<vector<double>> & data);
static void writeTsvUintData(const string & filename, const vector<vector<uint>> &data);
static void writeString(const string & fileName, const string &content);
/// bayes reshape
static uint vectorToNumber(const vector<uint> &numValues,
const vector<uint> &values);
static vector<uint> numberToVector(const vector<uint> & numValues, uint value);
};
#endif /* UTILITY_H_ */