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

Comparing trunk/OOPSE-3.0/src/utils/next_combination.hpp (file contents):
Revision 1677 by tim, Thu Oct 28 20:41:18 2004 UTC vs.
Revision 1679 by tim, Thu Oct 28 21:28:04 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   * @brief STL next_permuationtation like combination sequence generator.
43 < * Given the first and last iterator of a sequence, next_combination iteratively generates all possible combination.
43 > * Given the first and last iterator of a sequence, next_combination iteratively generates all
44 > * possible combinations.
45 > * @return if more combination is availiable, otherwise return false
46   * @param iterContainer iterator container
47   * @param first the first iterator
48   * @param last the last iterator
49 < * @note first and last must be random access iterators and iterContainer must be the container which
50 < * element is iterator. And all of the iteratos in iterContainer must be within the range [first, last)
49 > * @note first and last must be random access iterators and iterContainer must be the container of  
50 > * random access iterators . And all of the iteratos in iterContainer must be within the range [first, last)
51   *
52   * @code
53   * std::vector<int> iv;
# Line 63 | Line 64 | namespace oopse {
64   * //1
65   * //8
66   * //1  8
67 + * @endcode
68   */
69   template<class RandomAccessIterator, template<typename ELEM, typename = std::allocator<ELEM> > class IteratorContainer>
70   bool next_combination(IteratorContainer<RandomAccessIterator>& iterContainer, RandomAccessIterator first, RandomAccessIterator last) {
# Line 128 | Line 130 | bool replaceWildCard(std::vector<std::vector<std::stri
130      }
131   } //end next_combination
132  
133 + /**
134 + * @brief iteratively replace the sequence with wild cards
135 + * @return true if more combination sequence is avaliable, otherwise return true
136 + * @param cont iterator container, if expect whole series of combination, just pass an empty iterator
137 + * container. The user should not modify the iterator container
138 + * @param sequence the whole sequence used to generate combination
139 + * @param result a possible combination sequence which is set on return
140 + * @wildCard the wild card string. Its value is "X" by default
141 + * @note since next_combination never returns an empty sequence, replaceWildCard will not generate
142 + * one special combination, which is n identical wild cards (n is equal to the size of the passing sequence)
143 + *
144 + * @code
145 + * std::vector<std::string> sv;
146 + * std::vector<std::vector<std::string>::iterator> sic;
147 + * std::vector<std::string> resultString;
148 + * sv.push_back("H");
149 + * sv.push_back("C");
150 + * sv.push_back("N");
151 +
152 + * while (replaceWildCard(sic, sv, resultString)) {  
153 + *     for(std::vector<std::string>::iterator i = resultString.begin(); i != resultString.end(); ++i) {
154 + *         std::cout << *i << "\t";
155 + *     }
156 + *     std::cout << std::endl;
157 + * }
158 + * //output
159 + * //H X X
160 + * //X C X
161 + * //X X N
162 + * //H C X
163 + * //H X N
164 + * //X C N
165 + * //H C N
166 + @endcode
167 + */
168   bool replaceWildCard(std::vector<std::vector<std::string>::iterator>& cont,
169                                               std::vector<std::string>& sequence, std::vector<std::string>& result,
170                                               const std::string& wildCard = "X") {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines