/******************************************************************************************** ezwSelec.cpp Jim Millard for CO311 EZwindows sort visualization for Selection Sort ********************************************************************************************/ #include "ezwSelec.h" #include "ezwSwap.h" #include "ezwUtils.h" void SelectionSort(SimpleWindow& W, RaySegment* ptrR[], int A[], const int size, const short load) { for (int current = 0; current < size; current++) { int smallest = A[current]; int target = current; for (int i = current+1; i < size; i++) { if (A[i] < smallest) { smallest = A[i]; target = i; } } if (target > current) { Swap(A[current], A[target]); Swap(W, *ptrR[current], *ptrR[target], load); } Highlight(*ptrR[current],Green); } return; }