-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.h
63 lines (36 loc) · 1.66 KB
/
header.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef __LONELYPARTYARRAY_H
#define __LONELYPARTYARRAY_H
// Directives and Definitions
#include <limits.h>
#define UNUSED INT_MIN
#define LPA_SUCCESS -1911319927
#define LPA_FAILURE -1911319928
typedef struct LonelyPartyArray
{
int size; // number of occupied cells across all fragments
int num_fragments; // number of fragments (arrays) in this struct
int fragment_length; // number of cells per fragment
int num_active_fragments; // number of allocated (non-NULL) fragments
int **fragments; // array of pointers to individual fragments
int *fragment_sizes; // stores number of used cells in each fragment
} LonelyPartyArray;
typedef LonelyPartyArray LPA;
// Functional Prototypes
LonelyPartyArray *createLonelyPartyArray(int num_fragments, int fragment_length);
LonelyPartyArray *destroyLonelyPartyArray(LonelyPartyArray *party);
LonelyPartyArray *cloneLonelyPartyArray(LonelyPartyArray *party); // optional (bonus)
int set(LonelyPartyArray *party, int index, int key);
int get(LonelyPartyArray *party, int index);
int delete(LonelyPartyArray *party, int index);
int containsKey(LonelyPartyArray *party, int key);
int isSet(LonelyPartyArray *party, int index);
int printIfValid(LonelyPartyArray *party, int index);
LonelyPartyArray *resetLonelyPartyArray(LonelyPartyArray *party);
int getSize(LonelyPartyArray *party);
int getCapacity(LonelyPartyArray *party);
int getAllocatedCellCount(LonelyPartyArray *party);
long long unsigned int getArraySizeInBytes(LonelyPartyArray *party);
long long unsigned int getCurrentSizeInBytes(LonelyPartyArray *party);
double difficultyRating(void);
double hoursSpent(void);
#endif