public void InitNoiseFunctions( [NotNull] Random rand )
{
if ( rand == null )
throw new ArgumentNullException( "rand" );
// Fill empty
for ( int i = 0; i < permutation.Length; i++ ) {
permutation[i] = -1;
}
// Generate random numbers
for ( int i = 0; i < permutation.Length; i++ ) {
while ( true ) {
int iP = rand.Next() % permutation.Length;
if ( permutation[iP] == -1 ) {
permutation[iP] = i;
break;
}
}
}
// Copy
for ( int i = 0; i < permutation.Length; i++ ) {
p[permutation.Length + i] = p[i] = permutation[i];
}
}