Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

##Bug##

Bug

I only scanned your code briefly, but it looks to me like this code that is in your main loop:

 currentPoint = getRandomPoint();
 mitchellPoints.add(currentPoint);
 currentPointIndex++;

should be outside the loop. Otherwise you are adding one completely random point along with one Mitchell point on every iteration. I think that code was only meant to generate the first point.

##Unnecessary Hashing##

Unnecessary Hashing

One other thing I noticed is that you used a HashMap to store your minimal distances. You could instead just make an array of doubles of the same length as your array of points. It would be faster because it would eliminate the need for hashing and comparing of keys (all your keys are unique).

##Bug##

I only scanned your code briefly, but it looks to me like this code that is in your main loop:

 currentPoint = getRandomPoint();
 mitchellPoints.add(currentPoint);
 currentPointIndex++;

should be outside the loop. Otherwise you are adding one completely random point along with one Mitchell point on every iteration. I think that code was only meant to generate the first point.

##Unnecessary Hashing##

One other thing I noticed is that you used a HashMap to store your minimal distances. You could instead just make an array of doubles of the same length as your array of points. It would be faster because it would eliminate the need for hashing and comparing of keys (all your keys are unique).

Bug

I only scanned your code briefly, but it looks to me like this code that is in your main loop:

 currentPoint = getRandomPoint();
 mitchellPoints.add(currentPoint);
 currentPointIndex++;

should be outside the loop. Otherwise you are adding one completely random point along with one Mitchell point on every iteration. I think that code was only meant to generate the first point.

Unnecessary Hashing

One other thing I noticed is that you used a HashMap to store your minimal distances. You could instead just make an array of doubles of the same length as your array of points. It would be faster because it would eliminate the need for hashing and comparing of keys (all your keys are unique).

added 311 characters in body
Source Link
JS1
  • 28.9k
  • 3
  • 41
  • 83

##Bug##

I only scanned your code briefly, but it looks to me like this code that is in your main loop:

 currentPoint = getRandomPoint();
 mitchellPoints.add(currentPoint);
 currentPointIndex++;

should be outside the loop. Otherwise you are adding one completely random point along with one Mitchell point on every iteration. I think that code was only meant to generate the first point.

##Unnecessary Hashing##

One other thing I noticed is that you used a HashMap to store your minimal distances. You could instead just make an array of doubles of the same length as your array of points. It would be faster because it would eliminate the need for hashing and comparing of keys (all your keys are unique).

##Bug##

I only scanned your code briefly, but it looks to me like this code that is in your main loop:

 currentPoint = getRandomPoint();
 mitchellPoints.add(currentPoint);
 currentPointIndex++;

should be outside the loop. Otherwise you are adding one completely random point along with one Mitchell point on every iteration. I think that code was only meant to generate the first point.

##Bug##

I only scanned your code briefly, but it looks to me like this code that is in your main loop:

 currentPoint = getRandomPoint();
 mitchellPoints.add(currentPoint);
 currentPointIndex++;

should be outside the loop. Otherwise you are adding one completely random point along with one Mitchell point on every iteration. I think that code was only meant to generate the first point.

##Unnecessary Hashing##

One other thing I noticed is that you used a HashMap to store your minimal distances. You could instead just make an array of doubles of the same length as your array of points. It would be faster because it would eliminate the need for hashing and comparing of keys (all your keys are unique).

Source Link
JS1
  • 28.9k
  • 3
  • 41
  • 83

##Bug##

I only scanned your code briefly, but it looks to me like this code that is in your main loop:

 currentPoint = getRandomPoint();
 mitchellPoints.add(currentPoint);
 currentPointIndex++;

should be outside the loop. Otherwise you are adding one completely random point along with one Mitchell point on every iteration. I think that code was only meant to generate the first point.

lang-java

AltStyle によって変換されたページ (->オリジナル) /