/********************************************************************************************
ezwBubbl.cpp
	Jim Millard
	for CO311

    EZwindows sort visualization for Bubble Sort

********************************************************************************************/
#include "ezwBubbl.h"

#include "ezwSwap.h"
#include "ezwUtils.h"

void BubbleSort(SimpleWindow& W, RaySegment* ptrR[], int A[], const int size, const short load)
    {
    bool DoneSorting;
    int end = size-1;
    do  {
        DoneSorting = true;
        for (int current = 0; current < end; current++)
            if (A[current] > A[current+1])
                {
                DoneSorting = false;
                Swap(A[current+1],A[current]);
                Swap(W, *ptrR[current+1], *ptrR[current], load);
                }
        Highlight(*ptrR[end],Green);
        end--;
        }
    while (!DoneSorting);
    return;
    }