Skip to content

Commit

Permalink
Fixed nextRandom()
Browse files Browse the repository at this point in the history
  • Loading branch information
mihxil committed Nov 1, 2024
1 parent 4174b00 commit 51c181b
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ public M newElement(@Square E[][] matrix) throws InvalidElementCreationException
public M nextRandom(Random random) {
while(true) {
try {
List<E> list = new ArrayList<>();
E[][] values = elementStructure.newMatrix(dimension, dimension);
for (int i = 0; i < dimension; i++) {
list.add(elementStructure.nextRandom(random));
for (int j = 0; j < dimension; j++) {
values[i][j] = elementStructure.nextRandom(random);
}
}
return newElement((E[]) list.toArray());
return newElement(values);
} catch (InvalidElementCreationException ie) {
//ignored
}
Expand Down

0 comments on commit 51c181b

Please sign in to comment.