diff options
-rw-r--r-- | include/array.h | 114 | ||||
-rw-r--r-- | include/list.h | 200 | ||||
-rw-r--r-- | include/queue.h | 30 | ||||
-rw-r--r-- | include/stack.h | 30 | ||||
-rw-r--r-- | include/utility.h | 115 |
5 files changed, 0 insertions, 489 deletions
diff --git a/include/array.h b/include/array.h deleted file mode 100644 index 05a6492..0000000 --- a/include/array.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef __ARRAY_H__ -#define __ARRAY_H__ - -#include "utility.h" - -/**********************************************************/ -/* This object is an array with dynamic table size. */ -/* methods: */ -/* init(addr of the array, size per entry, size) */ -/* The array's type depends on what user want to */ -/* store. For example: if you want an array for int, */ -/* you should decleare like "int* v", and call the */ -/* init() like this "init(&v, sizeof(int), 5)", and */ -/* it will initalize an array with 5 elements. */ -/* */ -/* free(addr of the array) */ -/* Free the memory the array use. Yous should call */ -/* it when you don't need the container. */ -/* */ -/* */ -/* getSize(addr of the array) */ -/* Return the number of elements. */ -/* */ -/* getEntrySize(addr of the array) */ -/* Return the size per entry, it dependent on what */ -/* type of data you store in the container. */ -/* */ -/* getEntry(addr of the array, index) */ -/* Return a const pointer which point to the entry */ -/* with the index you give. */ -/* */ -/* */ -/* setSize(addr of the array, new_size) */ -/* Resize the table to new_size. Note that it won't */ -/* initalize the newly element if you increase size. */ -/* */ -/* setEntry(addr of the array, index, data) */ -/* Let the element with index you give be data. */ -/* */ -/* */ -/* addBack(addr of the array, data) */ -/* Add an element which contain data at the back of */ -/* the array. */ -/* */ -/* delBack(addr of the array) */ -/* Remove the last element of the array. */ -/* */ -/* addFront(addr of the array, data) !! UNFINISHED !! */ -/* Add an element which contain data at the front of */ -/* the array. */ -/* */ -/* delFront(addr of the array) !! UNFINISHED !! */ -/* Remove the first element of the array. */ -/* */ -/* */ -/* cat(addr of the v1, addr of the v2) */ -/* Concatenate the array2 to the back of array1. */ -/* */ -/* copy(addr of the v1, addr of the v2) */ -/* Let the contain in the v1 be the one in the v2 */ -/* */ -/* replace(addr of the v1, a, b, addr of the v2, x, y) */ -/* If b == 0, it will insert v2[x ... x+y-1] into */ -/* the place between v[a] */ -/* and v[a-1] */ -/* If y >= 0, it will replace v1[a ... a+b-1] */ -/* to v2[x ... x+y-1] */ -/* If y < 0, it will replace v1[a ... a+b-1] */ -/* to v2[x-y-1 ... x] with */ -/* reverse order. */ -/* */ -/**********************************************************/ - -pvoid ctl_array_initX(ppvoid v, size_t size, uint count); -pvoid ctl_array_freeX(ppvoid v); - -int ctl_array_getSizeX (ppvoid v); -pcvoid ctl_array_getEntryX (ppvoid v, uint index); -int ctl_array_getEntrySizeX(ppvoid v); - -int ctl_array_setSizeX (ppvoid v, uint count); -pvoid ctl_array_setEntryX(ppvoid v, uint index, pcvoid data); - -int ctl_array_addBackX (ppvoid v, pcvoid entry); -int ctl_array_delBackX (ppvoid v); -//int ctl_array_addFrontX(ppvoid v, pcvoid entry); -//int ctl_array_delFrontX(ppvoid v); - -int ctl_array_catX (ppvoid v, ppcvoid v2); -pvoid ctl_array_copyX (ppvoid v, ppcvoid v2); -int ctl_array_replaceX(ppvoid v , uint i1, uint ct1, - ppcvoid v2, uint j1, int ct2); - -#define ctl_array_init(X,Y,Z) ctl_array_initX(ppVoid(X),Y,Z) -#define ctl_array_free(X) ctl_array_freeX(ppVoid(X)) - -#define ctl_array_getSize(X) ctl_array_getSizeX (ppVoid(X)) -#define ctl_array_getEntry(X,Y) ctl_array_getEntryX (ppVoid(X),Y) -#define ctl_array_getEntrySize(X) ctl_array_getEntrySizeX(ppVoid(X)) - -#define ctl_array_setSize(X,Y) ctl_array_setSizeX (ppVoid(X),Y) -#define ctl_array_setEntry(X,Y,Z) ctl_array_setEntryX(ppVoid(X),Y,pcVoid(Z)) - -#define ctl_array_addBack(X,Y) ctl_array_addBackX(ppVoid(X),pcVoid(Y)) -#define ctl_array_delBack(X) ctl_array_delBackX(ppVoid(X)) -//#define ctl_array_addFront(X,Y) ctl_array_addBackX(ppVoid(X),pcVoid(Y)) -//#define ctl_array_delFront(X) ctl_array_delBackX(ppVoid(X)) - -#define ctl_array_cat(X,Y) ctl_array_catX (ppVoid(X),ppcVoid(Y)) -#define ctl_array_copy(X,Y) ctl_array_copyX(ppVoid(X),ppcVoid(Y)) -#define ctl_array_replace(X,Y,Z,A,B,C) ctl_array_replaceX( ppVoid(X),Y,Z,\ - ppcVoid(A),B,C) - -#endif /* __ARRAY_H_ */ diff --git a/include/list.h b/include/list.h deleted file mode 100644 index 8b802f5..0000000 --- a/include/list.h +++ /dev/null @@ -1,200 +0,0 @@ -#ifndef __list_h__ -#define __list_h__ - -#include "utility.h" - -/**********************************************************/ -/* This object is a double link list. */ -/* methods: */ -/* init(addr of the list, size per entry, list size) */ -/* The list's type depends on what user want to store*/ -/* . For example: if you want a list for int, you s- */ -/* hould declare like "int* v", and call the init() */ -/* like "init(&v, sizeof(int), 5)", which will creat */ -/* a double link list with 5 elements. */ -/* */ -/* free(addr of the list) */ -/* Free the memory the list use. You should call it */ -/* when you don't need the container. */ -/* */ -/* */ -/* getSize(addr of the list) */ -/* Return the number of elements. */ -/* */ -/* getEntrySize(addr of the list) */ -/* Return the size per entry, it dependent on what */ -/* type of data you store in the container. */ -/* */ -/* getFront(addr of the list) */ -/* Return a const pointer which point to the entry */ -/* at the head of the list. */ -/* */ -/* getBack(addr of the list) */ -/* Return a const pointer which point to the entry */ -/* at the end of the list. */ -/* */ -/* getBegin(addr of the list) */ -/* Return a pointer which point to the iterator at */ -/* the head of the list. */ -/* */ -/* getEnd(addr of the list) */ -/* Return a pointer which point to the iterator at */ -/* the end of the list (which cannot be modified). */ -/* */ -/* */ -/* setSize(addr of the list, new_size) */ -/* Resize the lsit to new_size at the back of the */ -/* list. Note that it won't initalize the newly ele- */ -/* ments when you increase the size. */ -/* */ -/* setFront(addr of the list, data) */ -/* Let the first element be the data you given. */ -/* */ -/* setBack(addr of the list, data) */ -/* Let the last element be the data you given. */ -/* */ -/* */ -/* addBack(addr of the list, data) */ -/* Add an element which contain data at the back of */ -/* the list. */ -/* */ -/* delBack(addr of the list) */ -/* Remove the last element of the list. */ -/* */ -/* addFront(addr of the list, data) */ -/* Add an element which contain data at the front of */ -/* the list. */ -/* */ -/* delFront(addr of the list) */ -/* Remove the first element of the list. */ -/* */ -/* */ -/* rm(addr of the list, addr of the iter1, iter2) */ -/* Remove the part of iter1 ~ iter2 (include iter1 */ -/* but not iter2) */ -/* */ -/* copy(addr of the list, addr of the iter1, iter2, */ -/* addr of the list2) */ -/* Create a new list which contain the part of the */ -/* iter1 ~ iter2 (include iter1 but not iter2) and */ -/* saved it to list2. */ -/* */ -/* move(addr of the list, addr of the iter1, iter2, */ -/* addr of the list2) */ -/* Move the part iter1 ~ iter2 to list2. */ -/* */ -/* swap(addr of the l1, addr of the iter. i1, i2, */ -/* addr of the l2, addr of the iter. j1, j2) */ -/* Swap the part of l1 from i1 to i2.previous and */ -/* the part of l2 from j1 to j2.previous. */ -/* */ -/* */ -/* iterGetEntry(addr of the iteator) */ -/* Return a const pointer which point to the data of */ -/* the iterator. */ -/* */ -/* iterGetNext(addr of the iterator) */ -/* Return a pointer which point to the next iterator */ -/* */ -/* iterGetPrev(addr of the iterator) */ -/* Return a pointer which point to the previous ite- */ -/* ator. */ -/* */ -/* */ -/* iterSetEntry(addr of the iterator, data) */ -/* Let the data which is stored in iterator be the */ -/* data you given. */ -/* */ -/* iterGoNext(addr of the iterator) */ -/* Instead of return a pointer, it will change the */ -/* pointer you given. */ -/* */ -/* iterGoPrev(addr of the iterator) */ -/* Instead of return a pointer, it will change the */ -/* pointer you given. */ -/* */ -/* */ -/* iterDel(addr of the iterator) */ -/* Delete the iterator you given, returning a pointer*/ -/* to the next iterator */ -/* */ -/* iterDelPrev(addr of the iterator) */ -/* Delete the previous of the iterator you given. */ -/* */ -/* iterDelPrev(addr of the iterator) */ -/* Delete the next of the iterator you given. */ -/* */ -/* */ -/**********************************************************/ - -pvoid ctl_list_initX(ppvoid l, size_t size, uint count); -pvoid ctl_list_freeX(ppvoid l); - -int ctl_list_getSizeX (ppcvoid l); -int ctl_list_getEntrySizeX(ppcvoid l); -pcvoid ctl_list_getFrontX (ppcvoid l); -pcvoid ctl_list_getBackX (ppcvoid l); -pvoid ctl_list_getBeginX (ppcvoid l); -pcvoid ctl_list_getEndX (ppcvoid l); - -int ctl_list_setSizeX (ppvoid l, uint count); -pvoid ctl_list_setFrontX(ppvoid l, pcvoid data); -pvoid ctl_list_setBackX (ppvoid l, pcvoid data); - -int ctl_list_addFrontX(ppvoid l, pcvoid data); -int ctl_list_delFrontX(ppvoid l); -int ctl_list_addBackX (ppvoid l, pcvoid data); -int ctl_list_delBackX (ppvoid l); - -int ctl_list_rmX (ppvoid li, pvoid i1, pvoid i2); -pvoid ctl_list_copyX(ppvoid li, pvoid i1, pvoid i2, ppvoid out); -pvoid ctl_list_moveX(ppvoid li, pvoid i1, pvoid i2, ppvoid out); -int ctl_list_swapX(ppvoid li, pvoid i1, pvoid i2, - ppvoid lj, pvoid j1, pvoid j2); - -pcvoid ctl_list_iterGetEntryX(pcvoid i); -pvoid ctl_list_iterGetNextX (pcvoid i); -pvoid ctl_list_iterGetPrevX (pcvoid i); - -pvoid ctl_list_iterSetEntryX(pvoid i, pcvoid data); - -pvoid ctl_list_iterDelX (pvoid i); -pvoid ctl_list_iterDelPrevX(pvoid i); -pvoid ctl_list_iterDelNextX(pvoid i); - -#define ctl_list_init(X,Y,Z) ctl_list_initX(ppVoid(X),Y,Z) -#define ctl_list_free(X) ctl_list_freeX(ppVoid(X)) - -#define ctl_list_getSize(X) ctl_list_getSizeX (ppcVoid(X)) -#define ctl_list_getEntrySize(X) ctl_list_getEntrySizeX(ppcVoid(X)) -#define ctl_list_getFront(X) ctl_list_getFrontX (ppcVoid(X)) -#define ctl_list_getBack(X) ctl_list_getBackX (ppcVoid(X)) -#define ctl_list_getBegin(X) ctl_list_getBeginX (ppcVoid(X)) -#define ctl_list_getEnd(X) ctl_list_getEndX (ppcVoid(X)) - -#define ctl_list_setSize(X,Y) ctl_list_setSizeX (ppVoid(X),Y) -#define ctl_list_setFront(X,Y) ctl_list_setFrontX(ppVoid(X),pcVoid(Y)) -#define ctl_list_setBack(X,Y) ctl_list_setBackX (ppVoid(X),pcVoid(Y)) - -#define ctl_list_addFront(X,Y) ctl_list_addFrontX(ppVoid(X),pcVoid(Y)) -#define ctl_list_delFront(X) ctl_list_delFrontX(ppVoid(X)) -#define ctl_list_addBack(X,Y) ctl_list_addBackX (ppVoid(X),pcVoid(Y)) -#define ctl_list_delBack(X) ctl_list_delBackX (ppVoid(X)) - - -#define ctl_list_rm(X,Y,Z) ctl_list_rmX (ppVoid(X),pVoid(Y),pVoid(Z)) -#define ctl_list_copy(X,Y,Z,A) ctl_list_copyX(ppVoid(X),pVoid(Y),pVoid(Z),ppVoid(A)) -#define ctl_list_move(X,Y,Z,A) ctl_list_moveX(ppVoid(X),pVoid(Y),pVoid(Z),ppVoid(A)) -#define ctl_list_swap(X,Y,Z,A,B,C) ctl_list_swapX(ppVoid(X),pVoid(Y),pVoid(Z),ppVoid(A),pVoid(B),pVoid(C)) - -#define ctl_list_iterGetEntry(X) ctl_list_iterGetEntryX(pcVoid(X)) -#define ctl_list_iterGetNext(X) ctl_list_iterGetNextX (pcVoid(X)) -#define ctl_list_iterGetPrev(X) ctl_list_iterGetPrevX (pcVoid(X)) - -#define ctl_list_iterSetEntry(X,Y) ctl_list_iterSetEntryX(pVoid(X),pcVoid(Y)) - -#define ctl_list_iterDel(X) ctl_list_iterDelX (pVoid(X)) -#define ctl_list_iterDelPrev(X) ctl_list_iterDelPrevX(pVoid(X)) -#define ctl_list_iterDelNext(X) ctl_list_iterDelNextX(pVoid(X)) - -#endif /* __list_h__ */ diff --git a/include/queue.h b/include/queue.h deleted file mode 100644 index 6799407..0000000 --- a/include/queue.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __QUEUE_H__ -#define __QUEUE_H__ - -#include "utility.h" - -pvoid ctl_queue_initX(ppvoid q, uint size); -pvoid ctl_queue_freeX(ppvoid q); - -uint ctl_queue_getEntrySizeX(ppcvoid q); -pcvoid ctl_queue_getFrontX (ppcvoid q); -int ctl_queue_isEmptyX (ppcvoid q); - -pcvoid ctl_queue_addX(ppvoid q, pcvoid data); -int ctl_queue_delX(ppvoid q); - -pvoid ctl_queue_copyX(ppcvoid q, ppvoid q2); - -#define ctl_queue_init(X,Y) ctl_queue_initX(ppVoid(X),Y) -#define ctl_queue_free(X) ctl_queue_freeX(ppVoid(X)) - -#define ctl_queue_getEntrySize(X) ctl_queue_getEntrySizeX(ppcVoid(X)) -#define ctl_queue_getFront(X) ctl_queue_getFrontX (ppcVoid(X)) -#define ctl_queue_isEmpty(X) ctl_queue_isEmptyX (ppcVoid(X)) - -#define ctl_queue_add(X,Y) ctl_queue_addX(ppVoid(X),pcVoid(Y)) -#define ctl_queue_del(X) ctl_queue_delX(ppVoid(X)) - -#define ctl_queue_copy(X,Y) ctl_queue_copyX(ppcVoid(X),ppVoid(Y)) - -#endif /* __QUEUE_H__ */ diff --git a/include/stack.h b/include/stack.h deleted file mode 100644 index a8815b4..0000000 --- a/include/stack.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __STACK_H__ -#define __STACK_H__ - -#include "utility.h" - -pvoid ctl_stack_initX(ppvoid s, uint size); -pvoid ctl_stack_freeX(ppvoid s); - -uint ctl_stack_getEntrySizeX(ppcvoid q); -int ctl_stack_isEmptyX (ppcvoid q); -pcvoid ctl_stack_getX (ppcvoid q); - -pcvoid ctl_stack_addX(ppvoid q, pcvoid data); -int ctl_stack_delX(ppvoid q); - -pvoid ctl_stack_copyX(ppcvoid q, ppvoid q2); - -#define ctl_stack_init(X,Y) ctl_stack_initX(ppVoid(X),Y) -#define ctl_stack_free(X) ctl_stack_freeX(ppVoid(X)) - -#define ctl_stack_getEntrySize(X) ctl_stack_getEntrySizeX(ppcVoid(X)) -#define ctl_stack_isEmpty(X) ctl_stack_isEmptyX (ppcVoid(X)) -#define ctl_stack_get(X) ctl_stack_getX (ppcVoid(X)) - -#define ctl_stack_add(X,Y) ctl_stack_addX(ppVoid(X),pcVoid(Y)) -#define ctl_stack_del(X) ctl_stack_delX(ppVoid(X)) - -#define ctl_stack_copy(X,Y) ctl_stack_copyX(ppcVoid(X),ppVoid(Y)) - -#endif /* __STACK_H__ */ diff --git a/include/utility.h b/include/utility.h deleted file mode 100644 index c8844e8..0000000 --- a/include/utility.h +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef __utility_h__ -#define __utility_h__ - -#include <stddef.h> - -/**********************************************************/ -/* This object contain some useful functions, constants */ -/* and types. */ -/* Enums: */ -/* ErrorType contain kinds of errors. */ -/* */ -/* Structures: */ -/* */ -/* Types: */ -/* uint unsigned int */ -/* pchar char* */ -/* ppchar char** */ -/* pvoid void* */ -/* ppvoid void** */ -/* cchar const char */ -/* pcchar (const char)* */ -/* ppcchar (const char)** */ -/* cvoid const void */ -/* pcvoid (cosnt void)* */ -/* ppcvoid (const void)** */ -/* ... etc */ -/* */ -/* Type transform: */ -/* Char(), pChar(), ppChar() */ -/* Void(), pVoid(), ppVoid() */ -/* cChar(), pcChar(), ppcChar() */ -/* cVoid(), pcVoid(), ppcVoid() */ -/* ... etc */ -/* */ -/* Functions: */ -/* ctl_malloc like malloc(), but will exit on error */ -/* ctl_realloc like realloc(), but will exit on erro */ -/* ctl_free like free(), but will return NULL */ -/* ctl_die print some message and exit() */ -/* ctl_swap swap two elements with given type */ -/* ctl_max return the max of the two arguments */ -/* ctl_min return the min of the two arguments */ -/* */ -/**********************************************************/ - -typedef enum{ - CTL_MEMORY = 0x01, - CTL_USER = 0x02 -} ErrorType; - -// int -typedef int* pint; -typedef unsigned int uint; -typedef uint* puint; -typedef const int cint; -typedef cint* pcint; -typedef const uint cuint; -typedef cuint* pcuint; -#define Int(X) (( int)(X)) -#define pInt(X) (( pint)(X)) -#define uInt(X) (( uint)(X)) -#define puInt(X) (( puint)(X)) -#define cInt(X) (( cint)(X)) -#define pcInt(X) (( pcint)(X)) -#define cuInt(X) (( cuint)(X)) -#define pcuInt(X) ((pcuint)(X)) - -// void -typedef void* pvoid; -typedef pvoid* ppvoid; -typedef const void cvoid; -typedef cvoid* pcvoid; -typedef pcvoid* ppcvoid; -#define Void(X) (( void)(X)) -#define pVoid(X) (( pvoid)(X)) -#define ppVoid(X) (( ppvoid)(X)) -#define cVoid(X) (( cvoid)(X)) -#define pcVoid(X) (( pcvoid)(X)) -#define ppcVoid(X) ((ppcvoid)(X)) - -// char -typedef char* pchar; -typedef pchar* ppchar; -typedef unsigned char uchar; -typedef uchar* puchar; -typedef puchar* ppuchar; -typedef const char cchar; -typedef cchar* pcchar; -typedef pcchar* ppcchar; -typedef const uchar cuchar; -typedef cuchar* pcuchar; -typedef pcuchar* ppcuchar; -#define Char(X) (( char)(X)) -#define pChar(X) (( pchar)(X)) -#define ppChar(X) (( ppchar)(X)) -#define uChar(X) (( uchar)(X)) -#define puChar(X) (( puchar)(X)) -#define ppuChar(X) (( ppuchar)(X)) -#define cChar(X) (( cchar)(X)) -#define pcChar(X) (( pcchar)(X)) -#define ppcChar(X) (( ppcchar)(X)) -#define cuChar(X) (( cuchar)(X)) -#define pcuChar(X) (( pcuchar)(X)) -#define ppcuChar(X) ((ppcuchar)(X)) - -pvoid ctl_malloc (size_t size); -pvoid ctl_realloc(pvoid ptr, size_t size); -pvoid ctl_free (pvoid ptr); -void ctl_die (ErrorType e); - -#define ctl_swap(X,Y,Z) do{X zzzztmp=(Y);(Y)=(Z);(Z)=zzzztmp;}while(0) -#define ctl_max(X,Y) ((X) > (Y) ? (X) : (Y)) -#define ctl_min(X,Y) ((X) < (Y) ? (X) : (Y)) - -#endif /* __utility_h__ */ |