-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector.h
More file actions
41 lines (31 loc) · 920 Bytes
/
vector.h
File metadata and controls
41 lines (31 loc) · 920 Bytes
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
/* IFJ20 - Vector (dynamic array) library
* Authors:
* Juraj Marticek, xmarti97
*/
#ifndef VECTOR_H
#define VECTOR_H
#include <stdlib.h>
#include <stdio.h>
#define DEFAULT_VECTOR_SIZE 20
typedef struct
{
unsigned length;
unsigned currentMaxLength;
const void **items;
} Vector;
Vector *vectorInit();
// Returns current number of items in vector
unsigned vectorLength(Vector *vector);
// Push new item into the vector
void vectorPush(Vector *vector, const void *item);
// Return and remove last item from vector
const void *vectorPop(Vector *vector);
// Insert item on given index
void vectorInsert(Vector *vector, const void *item, unsigned index);
// Remove item on given intex
void vectorRemove(Vector *vector, unsigned index);
// Return item on given index
const void *vectorGet(Vector *vector, unsigned index);
// Free allocated vector, and every item
void vectorFree(Vector *vector);
#endif