A C public library consists of common-used little functions and data-structures.
sort algorithm
- merge
data-structure:
- digraph
- binary-tree
- stack
- queue
- sequence-list
- single-link-list
algorithm:
- merge-sort
- quick-sort
- binaryInsertion-sort
- bubble-sort
- insertion-sort
- selection-sort
- kmp
digraph:
based on adjacency list
- include dg.h
- define a digraph by
ALGraph xx - use
alg_init(ALGraph *alGraph)to init a digraph - use
alg_create(ALGraph *alGraph)to create a digraph - use
alg_DFSTraverse(ALGraph *alGraph, void (*visit)(ALGraph *alGraph, int index))to do depth first traversal with the digraph - use
alg_BFSTraverse(ALGraph *alGraph, void (*visit)(ALGraph *alGraph, int index))to do breadth first traversal with the digraph
binary-tree:
- include bt.h (for threaded-binary-tree, include stack.h as well)
- define a binary-tree by
BT xx - use
bt_init(BT *rootpp)to init a binary-tree - use
bt_create(BT *rootpp)to create a binary-tree - use
bt_preOrderTraverse(BT rootp, void (*visit)(BTNode *nodep))
bt_inOrderTraverse(BT rootp, void (*visit)(BTNode *nodep))
bt_postOrderTraverse(BT rootp, void (*visit)(BTNode *nodep))
to traverse a binary-tree - use
bt_destroy(BT tree)to destroy a binary-tree
threaded-tree is all the same as the above, but :
- use
tbt_inOrderThreading(TBT rootp, Stack *nodes)to thread a binary-tree
Check bt_elem_type.h , bt.h and bt.c (tbt_elem_type.h , tbt.h , tbt.c) for more details
stack:
- include stack.h
- define a stack by
Stack xx - use
stack_init(Stack *stackp)to init a stack - use
stack_push(Stack *stackp, elem_type value)to push data into the stack - use
stack_pop(Stack *stackp)to pop data out of the stack - use
stack_getTop(Stack *stackp)to get the data in the top of the stack
Check stack.h, stack_storage.h and stack.c for more details
queue:
- include queue.h
- define a queue by
Queue xx - use
queue_init(Queue *queuep)to init a queue - use
queuep_isEmpty(Queue *queuep)to judge whether the queue is empty - use
queue_in(Queue *queuep, queue_elem_type value)to add data ino the tail of the queue - use
queue_getHead(Queue *queuep)to get the head element of the queue - use
queue_out(Queue *queuep)to bring the head element of the queue out - use
queue_destroy(Queue *queuep)to destroy the queue
Check queue.h and queue.c for more details
single-link-list:
- include sllist.h
- define a single-link-list by
SLList xx - use
sll_init(SLList *sll_headp)to init a single-link-list - use
sll_insert(SLList *sll, elem_type new_value)to insert data - use
sll_destroy(SLList sll_headp)to destroy a single-link-list
Check sllist.h and sllist.c for more details.
sequence-list:
- include sqlist.h
- define a sequence-list by
SqList xx - use
sql_init(SqList *sql, int size)to init a sequence-list - use
sql_insert(SqList *sql, int index, elem_type value)to insert data - use
sql_get(SqList *sql, int index)to get data - use
sql_getLen(SqList *sql)to get the length of the sequence-list - use
sql_grow(SqList *sql, int size)to make it bigger - use
sql_destroy(SqList *sql)to destroy it
Check sqlist.h and sqlist.c for more details
Still Not Complete !