ZE-Standard-Libraries/list/list.h

76 lines
3.8 KiB
C
Raw Normal View History

2018-06-12 05:51:42 +00:00
<EFBFBD><EFBFBD>#ifndef LIST_H
#define LIST_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef struct Node{
unsigned long long id;///UN&{
void *value;
int if_malloc;//<EFBFBD><EFBFBD>U_/f&T<EFBFBD>]<EFBFBD>~R<EFBFBD>YS<P
const char *type;//<EFBFBD><EFBFBD>U_<P<EFBFBD>v{|<EFBFBD>W
struct Node *next;
struct Node *last;
}Node;
typedef struct List{
unsigned long long id;///UN&{
Node *head;
Node *tail;
unsigned long long length;//<EFBFBD><EFBFBD>h<EFBFBD><EFBFBD><EFBFBD>^
}List;
2018-06-12 09:57:23 +00:00
int safeModeForNode(int ifon);//<EFBFBD>[hQ!j_nx<EFBFBD>O>f_<EFBFBD>X<EFBFBD>v<EFBFBD>QX[<EFBFBD><EFBFBD>O<EFBFBD><EFBFBD>ʑ>e
int releaseSingleListForsafeModeForNode(List *p_list);//ʑ>elist_list
int releaseSingleNodeForsafeModeForNode(List *p_list);//ʑ>enode_list
int releaseAllForNode(void);//<EFBFBD>[hQ!j_gT<EFBFBD>(u<EFBFBD>v<EFBFBD>Qpe
2018-06-12 05:51:42 +00:00
2018-06-12 09:03:31 +00:00
List *initList(void);
Node *initNode(void);
2018-06-12 05:51:42 +00:00
2018-06-12 11:07:12 +00:00
int initMallocValueForNode(Node *,const char *,void *);//K<EFBFBD><EFBFBD>N<EFBFBD>]RM<EFBFBD><EFBFBD>QX[<EFBFBD>v<P <EFBFBD>v^hf{|<EFBFBD>W
2018-06-12 05:51:42 +00:00
/* gsQid<EFBFBD>v<EFBFBD>Qpe*/
void init_rand(void);
unsigned long long getId(void);
/*<EFBFBD>ceQ<EFBFBD>Qpe*/
int insertInHead(List *p_list, Node *p_node);
int insertInTail(List *p_list, Node *p_node);
/*<EFBFBD>Nbc<EFBFBD>Qpe*/
int exchangeLocation(Node *p_node,Node *t_node);
/* Y6R<EFBFBD>Qpe*/
Node *copyNode(Node *);
/*<EFBFBD>yd<EFBFBD><EFBFBD>Qpe*/
2018-06-12 11:07:12 +00:00
int removeById(List *p_list, unsigned long long id);
2018-06-12 05:51:42 +00:00
int removeByNode(List *p_list, Node *p_node);
int popFromHead(List *p_list);
int popFromTail(List *p_list);
unsigned long long len(List *p_list);//<EFBFBD>g w<EFBFBD><EFBFBD>h<EFBFBD><EFBFBD>v<EFBFBD><EFBFBD>^
2018-06-12 09:57:23 +00:00
Node *findByIdForNode(List *p_list, const unsigned long long id);//<EFBFBD>Ǐid<EFBFBD>g~b<EFBFBD>vh<EFBFBD><EFBFBD>h<EFBFBD>-N<EFBFBD>v9SM<EFBFBD><EFBFBD><EFBFBD><EFBFBD>p
2018-06-12 05:51:42 +00:00
Node *findByValue(List *p_list, const char *type, const void *value);//<EFBFBD>Ǐ<Peg<EFBFBD>g~b<EFBFBD>vh<EFBFBD><EFBFBD>h<EFBFBD>-N<EFBFBD>v9SM<EFBFBD><EFBFBD><EFBFBD><EFBFBD>p
List *mply_findByValue(List *p_list, const char *type, const void *value);//<EFBFBD>[~bY*N<P9SM<EFBFBD><EFBFBD>v<EFBFBD><EFBFBD><EFBFBD>p
int releaseList(List *p_list);//ʑ>eListv^<EFBFBD>S <EFBFBD><EFBFBD>b/f&>e-N@b g<EFBFBD>vvQ-N<EFBFBD>vNode
int releaseListForSingle(List *p_list);//US<EFBFBD>>eList
int releaseNode(Node *p_node);//ʑ>eNode
2018-06-12 09:03:31 +00:00
int releaseOnlyNode(Node *p_node);//ʑ>eNode
2018-06-12 05:51:42 +00:00
int isListEmpty(List *p_list);//$R<EFBFBD>eList/f&T:Nzz
List *copyList(List *p_list);// Y6R<EFBFBD><EFBFBD>h<EFBFBD>
/* gsQ<EFBFBD>[hQ!j_<EFBFBD>v<EFBFBD>*/
2018-06-12 11:07:12 +00:00
int if_safeModeForNode;
List *node_list; //<EFBFBD>PX[<EFBFBD>X<EFBFBD>v<EFBFBD><EFBFBD><EFBFBD>p.
List *list_list; //<EFBFBD>PX[<EFBFBD>X<EFBFBD>v<EFBFBD><EFBFBD>h<EFBFBD>.
2018-06-12 09:03:31 +00:00
2018-06-12 05:51:42 +00:00
#endif