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

Comparing trunk/OOPSE-4/src/utils/next_combination.hpp (file contents):
Revision 1930 by gezelter, Wed Jan 12 22:41:40 2005 UTC vs.
Revision 2055 by tim, Mon Feb 21 15:22:56 2005 UTC

# Line 82 | Line 82 | template<class RandomAccessIterator, template<typename
82   * //1  8
83   * @endcode
84   */
85 < template<class RandomAccessIterator, template<typename ELEM, typename = std::allocator<ELEM> > class IteratorContainer>
86 < bool next_combination(IteratorContainer<RandomAccessIterator>& iterContainer, RandomAccessIterator first, RandomAccessIterator last) {
85 > template<class RandomAccessIterator>
86 > bool next_combination(std::vector<RandomAccessIterator>& iterContainer, RandomAccessIterator first, RandomAccessIterator last) {
87      if (first == last) {
88          return false;
89      }
90      
91      RandomAccessIterator endIter = --last;
92 <    typename IteratorContainer<RandomAccessIterator>::iterator i = iterContainer.end();
92 >    typename std::vector<RandomAccessIterator>::iterator i = iterContainer.end();
93      
94      if (iterContainer.empty()) {
95          //if sequence is empty, we insert the first iterator
# Line 109 | Line 109 | bool next_combination(IteratorContainer<RandomAccessIt
109          //If j is less than zero, it means it already reaches the last combination of current size.
110          //For instance, sequence may contain 6, 7, 8, 9 at this time, we need to increase the size
111          // of combination to 5
112 <        typename IteratorContainer<RandomAccessIterator>::iterator j = i;
112 >        typename std::vector<RandomAccessIterator>::iterator j = i;
113          j--;
114          while( j >= iterContainer.begin() && *i == *j + 1){
115              i--;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines