Code:
// POINT_BUBSORT.CPP
// Bubble sort function. Sorts an array of ints in descending order.
//template<class element>
void pointerBubbleSort(int *array, int n)
{
int *pointer = array;
int i, j, flag = 1;
int temp;
for(i = 1; (i <= n) && flag; i++)
{
flag = 0;
for(j = 0; j < (n - i); j++)
{
if (pointer[j + 1] < pointer[j])
{
temp = pointer[j + 1];
pointer[j + 1] = pointer[j];
pointer[j] = temp;
flag = 1;
}
}
// if (i%1000 == 0)
// cout << i << endl;
}
}
I want to use the apvector class with it, but I don't know how to use a template of pointers...
Code:
void pointerBubbleSort(int *array, int n)
{
int *pointer = array;
versus
Code:
template<class element>
void apvPointerBubbleSort(apvector <element*> array, int n)
{
apvector <element> *pointer = array;
How do I do the second one so that it will work?