ZE-Standard-Libraries/list/list.h

70 lines
1.5 KiB
C
Raw Normal View History

2018-07-23 04:59:16 +00:00
#ifndef LIST_H
#define LIST_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "../type/type.h"
2018-07-25 14:10:09 +00:00
#include "../id/id.h"
2018-07-23 04:59:16 +00:00
typedef struct Node{
2018-08-03 03:38:19 +00:00
SID *s_id;
2018-07-23 04:59:16 +00:00
void *value;
2018-08-03 03:38:19 +00:00
_Bool if_malloc;
2018-07-30 09:45:33 +00:00
_Bool if_sid;
2018-08-03 03:38:19 +00:00
unsigned int type;
2018-07-23 04:59:16 +00:00
struct Node *next;
struct Node *last;
} Node;
typedef struct List{
2018-08-03 03:38:19 +00:00
SID *s_id;
2018-07-23 04:59:16 +00:00
Node *head;
Node *tail;
2018-08-03 03:38:19 +00:00
unsigned long long length;
2018-07-23 04:59:16 +00:00
} List;
2018-08-03 03:38:19 +00:00
int safeModeForNode(int ifon);
int releaseSingleListForsafeModeForNode(List *p_list);
int releaseSingleNodeForsafeModeForNode(List *p_list);
int releaseAllForNode(void);
2018-07-23 04:59:16 +00:00
List *initList(void);
Node *initNode(void);
2018-08-03 03:38:19 +00:00
int initMallocValueForNode(Node *,unsigned int,void *);
2018-07-23 04:59:16 +00:00
int insertInHead(List *p_list, Node *p_node);
int insertInTail(List *p_list, Node *p_node);
int exchangeLocation(Node *p_node,Node *t_node);
Node *copyNode(Node *);
2018-07-30 09:45:33 +00:00
int removeById(List *p_list, const SID *s_id);
2018-07-23 04:59:16 +00:00
int removeByNode(List *p_list, Node *p_node);
int popFromHead(List *p_list);
int popFromTail(List *p_list);
2018-08-03 03:38:19 +00:00
unsigned long long len(List *p_list);
2018-07-23 04:59:16 +00:00
2018-08-03 03:38:19 +00:00
Node *findByIdForNode(List *p_list, const SID *s_id);
Node *findByValue(List *p_list, unsigned int type, const void *value);
List *mply_findByValue(List *p_list, unsigned int type, const void *value);
2018-07-23 04:59:16 +00:00
2018-08-03 03:38:19 +00:00
int releaseList(List *p_list);
int releaseListForSingle(List *p_list);
int releaseNode(Node *p_node);
int releaseOnlyNode(Node *p_node);
2018-07-23 04:59:16 +00:00
2018-08-03 03:38:19 +00:00
int isListEmpty(List *p_list);
List *copyList(List *p_list);
2018-07-23 04:59:16 +00:00
static int if_safeModeForNode;
2018-08-03 03:38:19 +00:00
static List *node_list;
static List *list_list;
2018-07-23 04:59:16 +00:00
#endif