-
Notifications
You must be signed in to change notification settings - Fork 1
/
arraylist.h
33 lines (29 loc) · 976 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
#ifndef ARRAYLIST_H
#define ARRAYLIST_H
/* GLOBALS */
enum { ALSUCCESS,
RMNODATA,
ALIDXOOR
};
typedef struct{
size_t data_size; /* the size of the data being stored */
size_t max_length; /* the current max length of the list */
size_t length; /* the current length of the list */
void *array;
int (*add)();
int (*remove)();
void *(*get)();
int (*set)();
void (*free)();
} ArrayList;
ArrayList *newArrayList( size_t data_size );
ArrayList *newArrayListSized( size_t data_size, size_t initial_length );
int ArrayList__getoffset( ArrayList *list, int index );
int ArrayList_add( ArrayList *list, void *data );
int ArrayList_remove( ArrayList *list, int index );
void ArrayList__realloc( ArrayList *list );
void *ArrayList_get( ArrayList *list, int index );
int ArrayList_set( ArrayList *list, int index, void *data );
void ArrayList_free( ArrayList *list );
char *ArrayList_toString( ArrayList *list );
#endif