Mercurial > repos > chrisd > testing
annotate 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 | 
| rev | line source | 
|---|---|
| 
0
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
1 #ifndef INT_UTIL_H | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
2 #define INT_UTIL_H | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
3 | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
4 #include <string> | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
5 #include <sstream> | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
6 | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
7 /** | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
8 * Given a string, return its integer. | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
9 */ | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
10 static inline int | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
11 s_to_i(const std::string &s) { | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
12 std::istringstream ss(s); | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
13 int i; | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
14 ss >> i; | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
15 return i; | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
16 } | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
17 | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
18 /** | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
19 * Given an integer, return a random number | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
20 * between 0 and i. | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
21 */ | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
22 static inline int | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
23 randomize(const int &i) { | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
24 return rand() % i; | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
25 } | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
26 | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
27 #endif /*INT_UTIL_H */ | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
28 | 
| 
 
f95150c37d38
planemo upload for repository https://github.com/ChrisD11/Tools commit ddc95e5d6b5f2c0a5340c0bc384aa822db8856d5
 
chrisd 
parents:  
diff
changeset
 | 
29 | 
