Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
qtypegeneric.h
1
9#ifndef QTYPEGENERIC_H
10#define QTYPEGENERIC_H
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16 #include <stdlib.h>
17 #include <stdint.h>
18 #include <stdbool.h>
19
20
27 typedef int (*qTypeGeneric_CompareFcn_t)( const void *, const void *, void * );
28 typedef int (*qTypeGeneric_ForEachFcn_t)( int, void *, void * );
38 void qTypeGeneric_Swap( void * const x,
39 void * const y,
40 size_t n );
41
67 void qTypeGeneric_Sort( void * const pbase,
68 size_t n,
69 size_t size,
70 qTypeGeneric_CompareFcn_t cmp,
71 void *arg );
72
83 void qTypeGeneric_Reverse( void * const pbase,
84 const size_t size,
85 const size_t init,
86 const size_t end );
87
99 void qTypeGeneric_Rotate( void * const pbase,
100 const size_t size,
101 const size_t n,
102 const int k );
103
113 void* qTypeGeneric_Set( void * const pbase,
114 const size_t size,
115 const size_t n,
116 const void * const ref );
117
154 void* qTypeGeneric_LSearch( const void *key,
155 const void *pbase,
156 const size_t n,
157 const size_t size,
158 qTypeGeneric_CompareFcn_t compar,
159 void *arg );
160
197 void* qTypeGeneric_BSearch( const void *key,
198 const void *pbase,
199 const size_t n,
200 const size_t size,
201 qTypeGeneric_CompareFcn_t compar,
202 void *arg );
233 int qTypeGeneric_ForEach( void *pbase,
234 const size_t size,
235 const size_t n,
236 qTypeGeneric_ForEachFcn_t f,
237 const bool dir,
238 void *arg );
239
242#ifdef __cplusplus
243}
244#endif
245
246#endif
void * qTypeGeneric_LSearch(const void *key, const void *pbase, const size_t n, const size_t size, qTypeGeneric_CompareFcn_t compar, void *arg)
Performs a linear search over an array of n elements pointed to by pbase for an element that matches ...
Definition qtypegeneric.c:264
void * qTypeGeneric_Set(void *const pbase, const size_t size, const size_t n, const void *const ref)
Set the data pointed by ref to every element of the array pointed by pbase. The array contains n elem...
Definition qtypegeneric.c:242
void * qTypeGeneric_BSearch(const void *key, const void *pbase, const size_t n, const size_t size, qTypeGeneric_CompareFcn_t compar, void *arg)
Performs a binary search over an array of n elements pointed to by pbase for an element that matches ...
Definition qtypegeneric.c:292
void qTypeGeneric_Sort(void *const pbase, size_t n, size_t size, qTypeGeneric_CompareFcn_t cmp, void *arg)
Sorts the given array pointed to by pbase in ascending order. The array contains n elements of size b...
Definition qtypegeneric.c:49
int qTypeGeneric_ForEach(void *pbase, const size_t size, const size_t n, qTypeGeneric_ForEachFcn_t f, const bool dir, void *arg)
Iterates n elements of the array pointed to by pbase. The size of each element is specified by size....
Definition qtypegeneric.c:331
void qTypeGeneric_Swap(void *const x, void *const y, size_t n)
Swaps the data pointed by x and y.
Definition qtypegeneric.c:21
void qTypeGeneric_Rotate(void *const pbase, const size_t size, const size_t n, const int k)
Rotates k elements of the array pointed to by pbase. The array contains n elements of size bytes....
Definition qtypegeneric.c:217
void qTypeGeneric_Reverse(void *const pbase, const size_t size, const size_t init, const size_t end)
Reverse the given array pointed to by pbase. Operation takes place on the portion of the array that s...
Definition qtypegeneric.c:197