1 |
< |
/* |
1 |
> |
/* |
2 |
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
|
* |
4 |
|
* The University of Notre Dame grants you ("Licensee") a |
46 |
|
#include "utils/next_combination.hpp" |
47 |
|
|
48 |
|
namespace oopse { |
49 |
< |
inline double roundMe( double x ){ |
50 |
< |
return ( x >= 0 ) ? floor( x + 0.5 ) : ceil( x - 0.5 ); |
51 |
< |
} |
49 |
> |
inline double roundMe( double x ){ |
50 |
> |
return ( x >= 0 ) ? floor( x + 0.5 ) : ceil( x - 0.5 ); |
51 |
> |
} |
52 |
|
|
53 |
< |
/** |
54 |
< |
* @brief iteratively replace the sequence with wild cards |
55 |
< |
* @return true if more combination sequence is avaliable, otherwise return true |
56 |
< |
* @param cont iterator container, if expect the whole series of combinations, pass an empty iterator |
57 |
< |
* container. The user should not modify this iterator container |
58 |
< |
* @param sequence the whole sequence used to generate combination |
59 |
< |
* @param result a possible combination sequence which is set on return |
60 |
< |
* @param wildCard the wild card string. Its value is "X" by default |
61 |
< |
* @note since next_combination never returns an empty sequence, replaceWildCard will not generate |
62 |
< |
* one special combination, which is n identical wild cards (n is equal to the size of the passing sequence) |
63 |
< |
* |
64 |
< |
* @code |
65 |
< |
* std::vector<std::string> sv; |
66 |
< |
* std::vector<std::vector<std::string>::iterator> sic; |
67 |
< |
* std::vector<std::string> resultString; |
68 |
< |
* sv.push_back("H"); |
69 |
< |
* sv.push_back("C"); |
70 |
< |
* sv.push_back("N"); |
53 |
> |
/** |
54 |
> |
* @brief iteratively replace the sequence with wild cards |
55 |
> |
* @return true if more combination sequence is avaliable, otherwise return true |
56 |
> |
* @param cont iterator container, if expect the whole series of combinations, pass an empty iterator |
57 |
> |
* container. The user should not modify this iterator container |
58 |
> |
* @param sequence the whole sequence used to generate combination |
59 |
> |
* @param result a possible combination sequence which is set on return |
60 |
> |
* @param wildCard the wild card string. Its value is "X" by default |
61 |
> |
* @note since next_combination never returns an empty sequence, replaceWildCard will not generate |
62 |
> |
* one special combination, which is n identical wild cards (n is equal to the size of the passing sequence) |
63 |
> |
* |
64 |
> |
* @code |
65 |
> |
* std::vector<std::string> sv; |
66 |
> |
* std::vector<std::vector<std::string>::iterator> sic; |
67 |
> |
* std::vector<std::string> resultString; |
68 |
> |
* sv.push_back("H"); |
69 |
> |
* sv.push_back("C"); |
70 |
> |
* sv.push_back("N"); |
71 |
|
|
72 |
< |
* while (replaceWithWildCard(sic, sv, resultString)) { |
73 |
< |
* for(std::vector<std::string>::iterator i = resultString.begin(); i != resultString.end(); ++i) { |
74 |
< |
* std::cout << *i << "\t"; |
75 |
< |
* } |
76 |
< |
* std::cout << std::endl; |
77 |
< |
* } |
78 |
< |
* //output |
79 |
< |
* //H X X |
80 |
< |
* //X C X |
81 |
< |
* //X X N |
82 |
< |
* //H C X |
83 |
< |
* //H X N |
84 |
< |
* //X C N |
85 |
< |
* //H C N |
86 |
< |
* @endcode |
87 |
< |
*/ |
88 |
< |
bool replaceWithWildCard(std::vector<std::vector<std::string>::iterator>& cont, |
89 |
< |
std::vector<std::string>& sequence, std::vector<std::string>& result, const std::string& wildCard = "X"); |
72 |
> |
* while (replaceWithWildCard(sic, sv, resultString)) { |
73 |
> |
* for(std::vector<std::string>::iterator i = resultString.begin(); i != resultString.end(); ++i) { |
74 |
> |
* std::cout << *i << "\t"; |
75 |
> |
* } |
76 |
> |
* std::cout << std::endl; |
77 |
> |
* } |
78 |
> |
* //output |
79 |
> |
* //H X X |
80 |
> |
* //X C X |
81 |
> |
* //X X N |
82 |
> |
* //H C X |
83 |
> |
* //H X N |
84 |
> |
* //X C N |
85 |
> |
* //H C N |
86 |
> |
* @endcode |
87 |
> |
*/ |
88 |
> |
bool replaceWithWildCard(std::vector<std::vector<std::string>::iterator>& cont, |
89 |
> |
std::vector<std::string>& sequence, std::vector<std::string>& result, const std::string& wildCard = "X"); |
90 |
|
} |
91 |
|
#endif |
92 |
|
|