Skip to content

Commit 0586297

Browse files
committed
fixed some radix sort colors
1 parent fb716b0 commit 0586297

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Assets/Scripts/ArrayController.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -703,18 +703,20 @@ IEnumerator CountingSort(int[] Array, int place) {
703703
//count number of occurrences in freq array
704704
for (int i = 0; i < n; i++) {
705705
yield return new WaitForSeconds(time);
706-
pillars[i].GetComponent<Pillar>().Color = tempColor;
706+
if (pillars[i].GetComponent<Pillar>().Color != nextColor)
707+
pillars[i].GetComponent<Pillar>().Color = swapColor;
707708
freq[(Array[i] / place) % 10]++;
708709
}
709710

710711
for (int i = 0; i < Array.Length; i++) {
711-
pillars[i].GetComponent<Pillar>().Color = whiteColor;
712+
if (pillars[i].GetComponent<Pillar>().Color != nextColor)
713+
pillars[i].GetComponent<Pillar>().Color = whiteColor;
712714
}
713715

714716
//Change count[i] so that count[i] now contains actual
715717
//position of this digit in output[]
716718
for (int i = 1; i < 10; i++) {
717-
yield return new WaitForSeconds(time);
719+
//yield return new WaitForSeconds(time);
718720
freq[i] += freq[i - 1];
719721
}
720722

@@ -723,11 +725,13 @@ IEnumerator CountingSort(int[] Array, int place) {
723725
yield return new WaitForSeconds(time);
724726
output[freq[(Array[i] / place) % 10] - 1] = Array[i];
725727
freq[(Array[i] / place) % 10]--;
726-
pillars[i].GetComponent<Pillar>().Color = tempColor;
728+
if (pillars[i].GetComponent<Pillar>().Color != nextColor)
729+
pillars[i].GetComponent<Pillar>().Color = tempColor;
727730
}
728731

729732
for (int i = 0; i < Array.Length; i++) {
730-
pillars[i].GetComponent<Pillar>().Color = whiteColor;
733+
if (pillars[i].GetComponent<Pillar>().Color != nextColor)
734+
pillars[i].GetComponent<Pillar>().Color = whiteColor;
731735
}
732736

733737
//Copy the output array to the input Array, Now the Array will

docs/Build/docs.data

-1 Bytes
Binary file not shown.

docs/Build/docs.wasm

207 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)