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

Comparing trunk/OOPSE-2.0/test/utils/next_combination.hpp (file contents):
Revision 1667 by tim, Thu Oct 28 15:02:54 2004 UTC vs.
Revision 1668 by tim, Thu Oct 28 15:42:17 2004 UTC

# Line 44 | Line 44 | template<class BidirectionalIterator, template<typenam
44   * <p> Preconditions: </p>
45   *
46   */
47 < template<class BidirectionalIterator, template<typename ELEM, typename = std::allocator<ELEM> > class IteratorContainer = std::vector>
48 < bool next_permutation(IteratorContainer<BidirectionalIterator>& iterContainer, BidirectionalIterator first, BidirectionalIterator last) {
47 > template<class BidirectionalIterator, template<typename ELEM, typename = std::allocator<ELEM> > class IteratorContainer>
48 > bool next_combination(IteratorContainer<BidirectionalIterator>& iterContainer, BidirectionalIterator first, BidirectionalIterator last) {
49      if (first == last) {
50          return false;
51      }
52      
53      BidirectionalIterator endIter = --last;
54 <    typename IteratorContainer::iterator i = iterContainer.end();
54 >    typename IteratorContainer<BidirectionalIterator>::iterator i = iterContainer.end();
55      
56      if (iterContainer.empty()) {
57          //if sequence is empty, we insert the first iterator
# Line 71 | Line 71 | bool next_permutation(IteratorContainer<BidirectionalI
71          //If j is less than zero, it means it already reaches the last combination of current size.
72          //For instance, sequence may contain 6, 7, 8, 9 at this time, we need to increase the size
73          // of combination to 5
74 <        typename IteratorContainer::iterator j = i;
74 >        typename IteratorContainer<BidirectionalIterator>::iterator j = i;
75          j--;
76          while( j >= first && *i == *j + 1){
77              i--;
# Line 96 | Line 96 | bool next_permutation(IteratorContainer<BidirectionalI
96              }            
97          } else {
98              ++(*j);
99 <            for(bidirIter = *j; i != iterContainer.size(); ++i, ++biDirIter) {
99 >            for(biDirIter = *j; i != iterContainer.end(); ++i, ++biDirIter) {
100                  *i = biDirIter;
101              }
102              return true;
103          }
104      }
105 < }
105 > } //end next_combination
106  
107 + } //end namespace oopse
108   #endif //UTILS_NEXT_COMBINATION_HPP
109  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines