TPCCLIB
Loading...
Searching...
No Matches
sort.c File Reference

Functions for sorting simple arrays. More...

#include "tpcclibConfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "tpcextensions.h"
#include "tpcstatist.h"

Go to the source code of this file.

Functions

void statSortInt (int *data, unsigned int n, int order)
void statSortUnsigned (unsigned int *data, unsigned int n, int order)
void statSortDouble (double *data, unsigned int n, int order)

Detailed Description

Functions for sorting simple arrays.

Definition in file sort.c.

Function Documentation

◆ statSortDouble()

void statSortDouble ( double * data,
unsigned int n,
int order )

Sort the given double list into ascending or descending order.

Author
Vesa Oikonen
Parameters
dataPointer to data array of size n
nLength of data array
orderAscending (0) or descending (<>0) order

Definition at line 99 of file sort.c.

106 {
107 if(n<2 || data==NULL) return;
108 if(order==0) qsort(data, n, sizeof(double), statDoubleCompAsc);
109 else qsort(data, n, sizeof(double), statDoubleCompDesc);
110}

Referenced by tacInput2sim().

◆ statSortInt()

void statSortInt ( int * data,
unsigned int n,
int order )

Sort the given integer list into ascending or descending order.

Author
Vesa Oikonen
Parameters
dataPointer to data array of size n
nLength of data array
orderAscending (0) or descending (<>0) order

Definition at line 63 of file sort.c.

70 {
71 if(n<2 || data==NULL) return;
72 if(order==0) qsort(data, n, sizeof(int), statIntCompAsc);
73 else qsort(data, n, sizeof(int), statIntCompDesc);
74}

◆ statSortUnsigned()

void statSortUnsigned ( unsigned int * data,
unsigned int n,
int order )

Sort the given unsigned integer list into ascending or descending order.

Author
Vesa Oikonen
Parameters
dataPointer to data array of size n
nLength of data array
orderAscending (0) or descending (<>0) order

Definition at line 81 of file sort.c.

88 {
89 if(n<2 || data==NULL) return;
90 if(order==0) qsort(data, n, sizeof(unsigned int), statUnsignedCompAsc);
91 else qsort(data, n, sizeof(unsigned int), statUnsignedCompDesc);
92}