This repository was archived by the owner on Dec 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommonMethod.cpp
More file actions
100 lines (56 loc) · 1.48 KB
/
commonMethod.cpp
File metadata and controls
100 lines (56 loc) · 1.48 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#define M_PI 3.1416
#include "r_tree/commonMethod.h"
#include <stdlib.h>
#include <math.h>
#include <fstream>
#include <string>
#include <map>
#include <bitset>
#include "sstream"
#include <unordered_map>
using namespace std;
vector< string > commonMethod::split(string s, string sep)
{
int pos1 = 0, pos2, pos=0;
pos2 = s.find(sep);
vector<string> token;
while(string::npos != pos2){
token.push_back(s.substr(pos1, pos2-pos1));
pos1 = pos2+1;
pos2 = s.find(sep, pos1);
}
token.push_back(s.substr(pos1));
return token;
}
double commonMethod::rad(double d)
{
return d * M_PI / 180.0;
}
vector< int > commonMethod::split_int(string s, string sep)
{
int pos1 = 0, pos2, pos=0;
pos2 = s.find(sep);
vector<int> token;
while(string::npos != pos2){
string ss=s.substr(pos1, pos2-pos1);
token.push_back(atoi(ss.c_str()));
pos1 = pos2+1;
pos2 = s.find(sep, pos1);
}
token.push_back(atoi(s.substr(pos1).c_str()));
return token;
}
vector< float > commonMethod::split_float(string s, string sep)
{
int pos1 = 0, pos2, pos=0;
pos2 = s.find(sep);
vector<float> token;
while(string::npos != pos2){
string ss=s.substr(pos1, pos2-pos1);
token.push_back(atof(ss.c_str()));
pos1 = pos2+1;
pos2 = s.find(sep, pos1);
}
token.push_back(atoi(s.substr(pos1).c_str()));
return token;
}