1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #define LIST \
- struct LISTNAME { \
- int size; \
- LISTTYPE[] data; \
- }; \
- \
- void listNew(LISTNAME list) { \
- list.size = 0; \
- list.data = new LISTTYPE[4]; \
- } \
- \
- void listAdd(LISTNAME list, LISTTYPE i) { \
- int l = length(list.data); \
- if(list.size >= l) { \
- LISTTYPE[] newData = new LISTTYPE[l * 2]; \
- for(int k = 0; k < l; k++) { \
- newData[k] = list.data[k]; \
- } \
- list.data = newData; \
- } \
- list.data[list.size] = i; \
- list.size++; \
- } \
- \
- int listGetLength(LISTNAME list) { \
- return list.size; \
- } \
- \
- LISTTYPE listGetIndex(LISTNAME list, int index) { \
- return list.data[index]; \
- }
- #define LISTNAME IntList
- #define LISTTYPE int
- LIST
- #undef LISTNAME
- #undef LISTTYPE
- #define LISTNAME FloatList
- #define LISTTYPE float
- LIST
|