Algorithms_in_C
1.0.0
Set of algorithms implemented in C.
Loading...
Searching...
No Matches
carray.h
1
/*
2
* CArray.h
3
*
4
* Author: Leonardo Vencovsky
5
* Created on 18/03/2018
6
*
7
* Modified by: Leonardo Vencovsky
8
* Last modified: 19/03/2018
9
*
10
* Header for Array in C
11
*
12
* Compiled in Visual Studio 2017
13
*
14
*/
15
16
#pragma once
17
18
#ifdef __cplusplus
19
extern
"C"
20
{
21
#endif
22
23
#define ARRAY_ERASED -1
24
#define SUCCESS 0
25
#define INVALID_POSITION 1
26
#define POSITION_INIT 2
27
#define POSITION_NOT_INIT 3
28
#define POSITION_EMPTY 4
29
#define ARRAY_FULL 5
30
31
typedef
struct
CArray
32
{
33
int
*array;
34
int
size;
35
}
CArray
;
36
37
// +-------------------------------------+
38
// | Returns array |
39
// +-------------------------------------+
40
CArray
*getCArray(
int
size);
41
CArray
*getCopyCArray(
CArray
*array);
42
43
// +-------------------------------------+
44
// | Input / Output |
45
// +-------------------------------------+
46
int
insertValueCArray(
CArray
*array,
int
position,
int
value);
47
int
removeValueCArray(
CArray
*array,
int
position);
48
int
pushValueCArray(
CArray
*array,
int
value);
49
int
updateValueCArray(
CArray
*array,
int
position,
int
value);
50
51
// +-------------------------------------+
52
// | Erase |
53
// +-------------------------------------+
54
int
eraseCArray(
CArray
*array);
55
56
// +-------------------------------------+
57
// | Switching |
58
// +-------------------------------------+
59
int
switchValuesCArray(
CArray
*array,
int
position1,
int
position2);
60
int
reverseCArray(
CArray
*array);
61
62
// +-------------------------------------+
63
// | Sorting |
64
// +-------------------------------------+
65
int
bubbleSortCArray(
CArray
*array);
66
int
selectionSortCArray(
CArray
*array);
67
int
insertionSortCArray(
CArray
*array);
68
int
blenderCArray(
CArray
*array);
69
70
// +-------------------------------------+
71
// | Searching |
72
// +-------------------------------------+
73
int
valueOcurranceCArray(
CArray
*array,
int
value);
74
CArray
*valuePositionsCArray(
CArray
*array,
int
value);
75
int
findMaxCArray(
CArray
*array);
76
int
findMinCArray(
CArray
*array);
77
78
// +-------------------------------------+
79
// | Display |
80
// +-------------------------------------+
81
int
displayCArray(
CArray
*array);
82
83
#ifdef __cplusplus
84
}
85
#endif
CArray
Definition
carray.h:32
data_structures
array
carray.h
Generated by
1.9.8