| 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 |
| 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--; |