public override void Generate( )
{
// create ascending permutation initially
for ( int i = 0; i < length; i++ )
{
val[i] = (ushort) i;
}
// shufle the permutation
for ( int i = 0, n = length >> 1; i < n; i++ )
{
ushort t;
int j1 = rand.Next( length );
int j2 = rand.Next( length );
// swap values
t = val[j1];
val[j1] = val[j2];
val[j2] = t;
}
}