Gaming32 / ArrayV

New home of https://github.com/MusicTheorist/ArrayVisualizer
MIT License
305 stars 47 forks source link

Fix Multiple-Sort Thread Duplicate Elements #33

Closed EmeraldBlock closed 3 years ago

EmeraldBlock commented 3 years ago

When using "Run X Sorts", duplicate elements could appear for seemingly no reason. This was caused by the sorting threads not setting the number of unique elements.

When the number of unique elements is larger than the array size (frequenty the case), this causes some elements to decrease by 1. This means that, on the typically-used linear distribution, duplicate elements often appear.

This is fixed by directly changing the array length slider, which not only auto-updates the uniques slider, but also makes the sliders properly update with the length change.

To achieve this, public methods are created in ArrayFrame.java, and the ArrayFrame instance is made publicly accessible.

Gaming32 commented 3 years ago

👏