Skip to content

Commit

Permalink
Fixed a bug in TVec::NextPerm()
Browse files Browse the repository at this point in the history
  • Loading branch information
profjure committed Jan 30, 2013
1 parent 7ab73a5 commit a30703f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions glib-core/ds.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ class TVec{
/// Reverses the order of the elements in the vector.
void Reverse();
/// Reverses the order of elements between <tt>LValN...RValN</tt>.
void Reverse(TSizeTy LValN, TSizeTy RValN){ while (LValN < RValN){Swap(LValN++, RValN--);} }
void Reverse(TSizeTy LValN, TSizeTy RValN){ Assert(LValN>=0 && RValN<Len()); while (LValN < RValN){Swap(LValN++, RValN--);} }
/// Sorts the vector and only keeps a single element of each value.
void Merge();

Expand Down Expand Up @@ -1150,7 +1150,7 @@ bool TVec<TVal, TSizeTy>::NextPerm() {
TSizeTy Mid = Last;
for (; GetVal(Next) >= GetVal(--Mid); ) { }
Swap(Next, Mid);
Reverse(Next1, Last);
Reverse(Next1, Last-1);
return true;
}
if (Next == First) { // pure descending, flip all
Expand Down

0 comments on commit a30703f

Please sign in to comment.