comparison gene_fraction/src/int_util.h @ 0:f95150c37d38 draft default tip

planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
author chrisd
date Sun, 21 Feb 2016 23:31:55 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f95150c37d38
1 #ifndef INT_UTIL_H
2 #define INT_UTIL_H
3
4 #include <string>
5 #include <sstream>
6
7 /**
8 * Given a string, return its integer.
9 */
10 static inline int
11 s_to_i(const std::string &s) {
12 std::istringstream ss(s);
13 int i;
14 ss >> i;
15 return i;
16 }
17
18 /**
19 * Given an integer, return a random number
20 * between 0 and i.
21 */
22 static inline int
23 randomize(const int &i) {
24 return rand() % i;
25 }
26
27 #endif /*INT_UTIL_H */
28
29