Skip to content

Commit

Permalink
优化运行效率
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev-XYS authored Nov 25, 2016
1 parent 4d36d39 commit fcdbb41
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Suffix-Array(Doubling).cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ int l;
char s[STRING_LENGTH];
int rank[STRING_LENGTH * 2], sa[STRING_LENGTH];

inline bool operator == (const sortinfo &x, const sortinfo &y)
{
return x.x == y.x && x.y == y.y;
}

void radix_sort(sortinfo *d)
{
static sortinfo _d[STRING_LENGTH], res[STRING_LENGTH];
Expand Down Expand Up @@ -88,7 +83,11 @@ void init_rank()
rank[d[0].ord] = 1;
for (int i = 1; i < l; i++)
{
rank[d[i].ord] = (d[i] == d[i - 1] ? x : ++x);
rank[d[i].ord] = (d[i].x == d[i - 1].x && d[i].y == d[i - 1].y ? x : ++x);
}
if (x == l)
{
break;
}
}
}
Expand Down

0 comments on commit fcdbb41

Please sign in to comment.