-
Notifications
You must be signed in to change notification settings - Fork 0
/
arrayutils.c
113 lines (97 loc) · 4.26 KB
/
arrayutils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "arrayutils.h"
uint8_t maxArrayU8( uint8_t * array, size_t size ) {
uint8_t m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m < array[i] ) m = array[i];
return m; }
uint16_t maxArrayU16( uint16_t * array, size_t size ) {
uint16_t m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m < array[i] ) m = array[i];
return m; }
uint32_t maxArrayU32( uint32_t * array, size_t size ) {
uint32_t m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m < array[i] ) m = array[i];
return m; }
uint64_t maxArrayU64( uint64_t * array, size_t size ) {
uint64_t m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m < array[i] ) m = array[i];
return m; }
char maxArrayChar( char * array, size_t size ) {
char m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m < array[i] ) m = array[i];
return m; }
int maxArrayInt( int * array, size_t size ) {
int m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m < array[i] ) m = array[i];
return m; }
float maxArrayFloat( float * array, size_t size ) {
float m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m < array[i] ) m = array[i];
return m; }
double maxArrayDouble( double * array, size_t size ) {
double m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m < array[i] ) m = array[i];
return m; }
uint8_t minArrayU8( uint8_t * array, size_t size ) {
uint8_t m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m > array[i] ) m = array[i];
return m; }
uint16_t minArrayU16( uint16_t * array, size_t size ) {
uint16_t m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m > array[i] ) m = array[i];
return m; }
uint32_t minArrayU32( uint32_t * array, size_t size ) {
uint32_t m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m > array[i] ) m = array[i];
return m; }
uint64_t minArrayU64( uint64_t * array, size_t size ) {
uint64_t m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m > array[i] ) m = array[i];
return m; }
char minArrayChar( char * array, size_t size ) {
char m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m > array[i] ) m = array[i];
return m; }
int minArrayInt( int * array, size_t size ) {
int m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m > array[i] ) m = array[i];
return m; }
float minArrayFloat( float * array, size_t size ) {
float m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m > array[i] ) m = array[i];
return m; }
double minArrayDouble( double * array, size_t size ) {
double m = array[0];
if( size <= 1 ) return m;
for( size_t i = 1; i < size; ++i ) if( m > array[i] ) m = array[i];
return m; }
void printArrayU8( uint8_t * array, size_t size ) {
printf("[ "); for( size_t i = 0; i < size; ++i ) printf("%hhu%s", array[i], i != size-1 ? ", " : " "); printf("]\n"); }
void printArrayU16( uint16_t * array, size_t size ) {
printf("[ "); for( size_t i = 0; i < size; ++i ) printf("%hu%s", array[i], i != size-1 ? ", " : " "); printf("]\n"); }
void printArrayU32( uint32_t * array, size_t size ) {
printf("[ "); for( size_t i = 0; i < size; ++i ) printf("%u%s", array[i], i != size-1 ? ", " : " "); printf("]\n"); }
void printArrayU64( uint64_t * array, size_t size ) {
printf("[ "); for( size_t i = 0; i < size; ++i ) printf("%lu%s", array[i], i != size-1 ? ", " : " "); printf("]\n"); }
void printArrayChar( char * array, size_t size ) {
printf("[ "); for( size_t i = 0; i < size; ++i ) printf("%c%s", array[i], i != size-1 ? ", " : " "); printf("]\n"); }
void printArrayInt( int * array, size_t size ) {
printf("[ "); for( size_t i = 0; i < size; ++i ) printf("%d%s", array[i], i != size-1 ? ", " : " "); printf("]\n"); }
void printArrayFloat( float * array, size_t size ) {
printf("[ "); for( size_t i = 0; i < size; ++i ) printf("%F%s", array[i], i != size-1 ? ", " : " "); printf("]\n"); }
void printArrayDouble( double * array, size_t size ) {
printf("[ "); for( size_t i = 0; i < size; ++i ) printf("%F%s", array[i], i != size-1 ? ", " : " "); printf("]\n"); }