-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.h
40 lines (38 loc) · 1.35 KB
/
list.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
#pragma once
#define IS_EMPTY_LIST(a) (a == NULL)
#define EMPTY_LIST NULL
#define makeTypeList(returnType, funcName, argType) returnType funcName(argType arg){\
return (returnType)makeList((void*)arg);\
}
#define appendType(returnType, funcName, argType) returnType funcName(returnType list, argType arg){\
return (returnType)appendToList(list, (void*)arg);\
}
#define prependType(returnType, funcName, argType) returnType funcName(returnType list, argType arg){\
return (returnType)prependToList(list, (void*)arg);\
}
#define getType(returnType, funcName, argType) returnType funcName(argType list){\
return (returnType)getPointer(list);\
}
#define concatType(returnType, funcName) returnType funcName(returnType l1, returnType l2){\
return (returnType)concatList((List*)l1, (List*)l2);\
}
struct _list {
union {
int number;
void* pointer;
} Value;
struct _list* Next;
};
typedef struct _list List;
List* makeList(void* Value);
List* makeInt(int Value);
List* appendToList(List* list, void* value);
List* appendToList(List* list, void* value);
List* prependToList(List* list, void* value) ;
List* prependToListInt(List* list, int value);
List* concatList(List* l1, List* l2);
List* makeCopy(List* l1) ;
List* getPointer(List* list);
List* popIntFromList(List* list);
int peekIntFromList(List* list);
int getNumber(List* list);