2018-03-20 02:09:22 +03:00
|
|
|
/*
|
|
|
|
* CArray.h
|
|
|
|
*
|
|
|
|
* Author: Leonardo Vencovsky
|
|
|
|
* Created on 18/03/2018
|
|
|
|
*
|
|
|
|
* Modified by: Leonardo Vencovsky
|
|
|
|
* Last modified: 19/03/2018
|
|
|
|
*
|
|
|
|
* Header for Array in C
|
|
|
|
*
|
|
|
|
* Compiled in Visual Studio 2017
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2020-05-29 23:23:24 +03:00
|
|
|
extern "C"
|
|
|
|
{
|
2018-03-20 02:09:22 +03:00
|
|
|
#endif
|
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
#define ARRAY_ERASED -1
|
|
|
|
#define SUCCESS 0
|
|
|
|
#define INVALID_POSITION 1
|
|
|
|
#define POSITION_INIT 2
|
|
|
|
#define POSITION_NOT_INIT 3
|
|
|
|
#define POSITION_EMPTY 4
|
|
|
|
#define ARRAY_FULL 5
|
2018-07-19 17:23:32 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
typedef struct CArray
|
|
|
|
{
|
|
|
|
int *array;
|
|
|
|
int size;
|
|
|
|
} CArray;
|
2018-03-20 02:09:22 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
// +-------------------------------------+
|
|
|
|
// | Returns array |
|
|
|
|
// +-------------------------------------+
|
|
|
|
CArray *getCArray(int size);
|
|
|
|
CArray *getCopyCArray(CArray *array);
|
2018-03-20 02:09:22 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
// +-------------------------------------+
|
|
|
|
// | Input / Output |
|
|
|
|
// +-------------------------------------+
|
|
|
|
int insertValueCArray(CArray *array, int position, int value);
|
|
|
|
int removeValueCArray(CArray *array, int position);
|
|
|
|
int pushValueCArray(CArray *array, int value);
|
|
|
|
int updateValueCArray(CArray *array, int position, int value);
|
2018-03-20 02:09:22 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
// +-------------------------------------+
|
|
|
|
// | Erase |
|
|
|
|
// +-------------------------------------+
|
|
|
|
int eraseCArray(CArray *array);
|
2018-03-20 02:09:22 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
// +-------------------------------------+
|
|
|
|
// | Switching |
|
|
|
|
// +-------------------------------------+
|
|
|
|
int switchValuesCArray(CArray *array, int position1, int position2);
|
|
|
|
int reverseCArray(CArray *array);
|
2018-03-20 02:09:22 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
// +-------------------------------------+
|
|
|
|
// | Sorting |
|
|
|
|
// +-------------------------------------+
|
|
|
|
int bubbleSortCArray(CArray *array);
|
|
|
|
int selectionSortCArray(CArray *array);
|
|
|
|
int insertionSortCArray(CArray *array);
|
|
|
|
int blenderCArray(CArray *array);
|
2018-03-20 02:09:22 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
// +-------------------------------------+
|
|
|
|
// | Searching |
|
|
|
|
// +-------------------------------------+
|
|
|
|
int valueOcurranceCArray(CArray *array, int value);
|
|
|
|
CArray *valuePositionsCArray(CArray *array, int value);
|
|
|
|
int findMaxCArray(CArray *array);
|
|
|
|
int findMinCArray(CArray *array);
|
2018-03-20 02:09:22 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
// +-------------------------------------+
|
|
|
|
// | Display |
|
|
|
|
// +-------------------------------------+
|
|
|
|
int displayCArray(CArray *array);
|
2018-03-20 02:09:22 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2018-07-19 17:23:32 +03:00
|
|
|
#endif
|