forked from domhoward14/module_3
/
ArrayList.h
45 lines (26 loc) · 987 Bytes
/
ArrayList.h
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
#ifndef ARRAYLIST_H_INCLUDED
#define ARRAYLIST_H_INCLUDED
// Default capacity for new ArrayLists
#define DEFAULT_INIT_LEN 10
typedef struct ArrayList
{
// We will store an array of strings (i.e., an array of char arrays)
char **array;
// Size of list (i.e., number of elements that have been added to the array)
int size;
// Length of the array (i.e., the array's current maximum capacity)
int capacity;
} ArrayList;
// Functional Prototypes
ArrayList *createArrayList(int length);
ArrayList *destroyArrayList(ArrayList *list);
ArrayList *expandArrayList(ArrayList *list, int length);
ArrayList *trimArrayList(ArrayList *list);
char *put(ArrayList *list, char *str);
char *get(ArrayList *list, int index);
char *set(ArrayList *list, int index, char *str);
char *insertElement(ArrayList *list, int index, char *str);
int removeElement(ArrayList *list, int index);
int getSize(ArrayList *list);
void printArrayList(ArrayList *list);
#endif // ARRAYLIST_H_INCLUDED