list.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #ifndef __LIST_H__
  4. #define __LIST_H__
  5. typedef struct node {
  6. int n; /* data field(s) */
  7. char * data; //数据
  8. char cmd; //发送的命令
  9. int len; //发送的长度
  10. /* float b;
  11. * char c;
  12. * ... etc.
  13. */
  14. struct node *next; /* pointer to next element */
  15. }Node;
  16. #if 0
  17. Node *newNode(int ); /* physically creates a new node */
  18. #else
  19. Node *newNode(int x,int cmd,char *data,int len);
  20. #endif
  21. /* N.B. this function is called by other functions because does not take care
  22. * of inserting the Node in the list, but delegates this operation to other
  23. * functions, such as *Insert functions */
  24. Node *preInsert(Node *, int,int,char *,int); /* inserts a new item at the top of the list */
  25. Node *orderInsert(Node *, int ,int,char *,int); /* inserts a new element in order, according to a key field */
  26. Node *postInsert(Node *, int ,int,char *,int); /* inserts a new item at the end of the list */
  27. Node *findNode(Node *, int ); /* find a node in the list */
  28. Node *deleteNode(Node *, int ); /* deletes a node corresponding to the inserted key */
  29. Node *deleteList(Node *); /* deletes a list */
  30. void printList(Node *); /* prints all the nodes in the list */
  31. void MergeSort(Node **); /* sorting algorithm */
  32. Node *Merge(Node *, Node *); /* merges two sorted linked lists */
  33. void Split(Node *, Node **, Node **); /* split the nodes of the list into two sublists */
  34. int countNodes(Node *); /* returns the number of nodes in the list */
  35. Node* copyList( Node* originalList);
  36. int countClockNodes_byCMD(Node *top,char type_cmd);
  37. Node *deleteNode_head(Node *top);
  38. #define MAX_MSG_ID_NUM 1000
  39. int allocateMsgIdNum();
  40. void deallocateMsgIdNum(int idNum);
  41. #if 0
  42. void wait_Send_Data_Insert(int msgid,uint8_t *data,int len);
  43. #endif
  44. void wait_Send_Data_Delete(int msgid);
  45. #endif