ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/utils/next_combination.hpp
(Generate patch)

Comparing trunk/OOPSE-2.0/src/utils/next_combination.hpp (file contents):
Revision 1677 by tim, Thu Oct 28 20:41:18 2004 UTC vs.
Revision 1678 by tim, Thu Oct 28 21:11:12 2004 UTC

# Line 39 | Line 39 | namespace oopse {
39   namespace oopse {
40  
41   /**
42 < * @fn bool next_combination(IteratorContainer<RandomAccessIterator>& iterContainer, RandomAccessIterator first, RandomAccessIterator last)
42 > * @fn bool next_combination(IteratorContainer<RandomAccessIterator>& iterContainer,
43 > *                                           RandomAccessIterator first, RandomAccessIterator last)
44   * @brief STL next_permuationtation like combination sequence generator.
45 < * Given the first and last iterator of a sequence, next_combination iteratively generates all possible combination.
45 > * Given the first and last iterator of a sequence, next_combination iteratively generates all
46 > * possible combination.
47 > * @return if more combination is availiable, otherwise return false
48   * @param iterContainer iterator container
49   * @param first the first iterator
50   * @param last the last iterator
51 < * @note first and last must be random access iterators and iterContainer must be the container which
52 < * element is iterator. And all of the iteratos in iterContainer must be within the range [first, last)
51 > * @note first and last must be random access iterators and iterContainer must be the container of  
52 > * random access iterators . And all of the iteratos in iterContainer must be within the range [first, last)
53   *
54   * @code
55   * std::vector<int> iv;
# Line 128 | Line 131 | bool replaceWildCard(std::vector<std::vector<std::stri
131      }
132   } //end next_combination
133  
134 + /**
135 + * @fn bool replaceWildCard(std::vector<std::vector<std::string>::iterator>& cont,
136 + *                                        std::vector<std::string>& sequence, std::vector<std::string>& result,
137 + *                                        const std::string& wildCard)
138 + * @brief iteratively replace the sequence with wild cards
139 + * @return true if more combination sequence is avaliable, otherwise return true
140 + * @param cont iterator container, if expect whole series of combination, just pass an empty iterator
141 + * container. The user should not modify the iterator container
142 + * @param sequence the whole sequence used to generate combination
143 + * @param result a possible combination sequence which is set on return
144 + * @wildCard the wild card string. Its value is "X" by default
145 + * @note since next_combination never returns an empty sequence, replaceWildCard will not generate
146 + * one special combination, which is n identical wild cards (n is equal to the size of the passing sequence)
147 + *
148 + * @code
149 + * std::vector<std::string> sv;
150 + * std::vector<std::vector<std::string>::iterator> sic;
151 + * std::vector<std::string> resultString;
152 + * sv.push_back("H");
153 + * sv.push_back("C");
154 + * sv.push_back("N");
155 +
156 + * while (replaceWildCard(sic, sv, resultString)) {  
157 + *     for(std::vector<std::string>::iterator i = resultString.begin(); i != resultString.end(); ++i) {
158 + *         std::cout << *i << "\t";
159 + *     }
160 + *     std::cout << std::endl;
161 + * }
162 + * //output
163 + * //H X X
164 + * //X C X
165 + * //X X N
166 + * //H C X
167 + * //H X N
168 + * //X C N
169 + * //H C N
170 + @endcode
171 + */
172   bool replaceWildCard(std::vector<std::vector<std::string>::iterator>& cont,
173                                               std::vector<std::string>& sequence, std::vector<std::string>& result,
174                                               const std::string& wildCard = "X") {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines