Data Structures Lerax  v3.0-101-gb1f7
Opinionated Data Structures & Algorithms
Loading...
Searching...
No Matches
sort.h File Reference

Go to the source code of this file.

Macros

#define Type   int
#define TypeFormat   "%d"

Functions

void bubblesort (Type *v, int n)
 Sorts an array of integers in ascending order using the bubble sort algorithm.
void insertionsort (Type *v, int n)
 Sorts an array of integers in ascending order using the insertion sort algorithm.
void mergesort (Type *v, int n)
 Sorts an array of integers in ascending order using the merge sort algorithm.
void quicksort (Type *v, int n)
 Sorts an array of integers in ascending order using the quicksort algorithm.
void heapsort (Type *v, int n)
 Sorts an array of integers in ascending order using the heapsort algorithm.
void radixsort (Type *v, int n)
 Sorts an array of integers in ascending order using the radix sort algorithm.
void selectionsort (Type *v, int n)
 Sorts an array of integers in ascending order using the selection sort algorithm.
void print_vector (Type *v, int n)
 Prints the elements of an array to the console.
void swap (Type *e1, Type *e2)
 Swaps the values of two integers.
int check_sorted (Type *v, int n)
 Checks if an array is sorted in ascending order.
Typerandom_vector (int n)
 Creates an array of random integers.
void debug_print_vector (Type *v, int n)
 Prints the elements of an array to the console if the DEBUG symbol is defined.
void debug (const char *format,...)
 Prints a debug message to the console if the DEBUG symbol is defined.

Macro Definition Documentation

◆ Type

#define Type   int

    Copyright 2017-2025 Manoel Vilela

    Author: Manoel Vilela
   Contact: manoel_vilela@engineer.com

Organization: UFC


◆ TypeFormat

#define TypeFormat   "%d"

Function Documentation

◆ check_sorted()

int check_sorted ( Type * v,
int n )

Checks if an array is sorted in ascending order.

Parameters
vThe array to check.
nThe number of elements in the array.
Returns
1 if the array is sorted, 0 otherwise.

◆ debug()

void debug ( const char * format,
... )

Prints a debug message to the console if the DEBUG symbol is defined.

Parameters
formatThe format string for the message.
...The arguments for the format string.

◆ debug_print_vector()

void debug_print_vector ( Type * v,
int n )

Prints the elements of an array to the console if the DEBUG symbol is defined.

Parameters
vThe array to print.
nThe number of elements in the array.

◆ print_vector()

void print_vector ( Type * v,
int n )

Prints the elements of an array to the console.

Parameters
vThe array to print.
nThe number of elements in the array.

◆ random_vector()

Type * random_vector ( int n)

Creates an array of random integers.

Parameters
nThe number of elements in the array.
Returns
A pointer to the new array.

◆ swap()

void swap ( Type * e1,
Type * e2 )

Swaps the values of two integers.

Parameters
e1A pointer to the first integer.
e2A pointer to the second integer.