C Project Template
list.h
Go to the documentation of this file.
1 
12 #ifndef LIST_H
13 #define LIST_H
14 
15 #include <stdio.h>
16 #include <assert.h>
17 #include <stdlib.h>
18 #include <string.h>
19 
20 #define MAX_LINES 1010
21 #define MAX_LEN_OPER_STR 100
22 
23 
24 typedef struct _node{
25  int data;
26  struct _node* ngb[2]; // neighbor
27 } node;
28 
29 typedef struct {
30  node* str;
31  node* end;
32 } list;
33 
34 
35 // Constructor and Descructor
36 node* init_node(int data);
37 list init_list(void);
38 void detach_list(list* line);
39 void kill_node(node*);
40 void kill_list(list*);
41 
42 int PrintList(list*);
43 int printNode(node* nStr);
44 int iter_read(node*);
45 
51 int iter_read(node*);
52 
54 int get_flag2node(node* terminal_node);
55 
62 int get_flag2null(node* terminal_node);
63 
64 /* Return the direction to the dst. -1 for missing */
65 int get_flag2dst(node* src, node* dst);
66 
67 
68 //Operations
69 
71 int leave(list*);
72 
79 int enter(list*, int log);
80 
87 void migrate(list* src, list* dst);
88 
89 
91 void interact_scanf(void);
92 
93 #endif
int get_flag2node(node *terminal_node)
Definition: list.c:91
int leave(list *)
Definition: list.c:131
int iter_read(node *)
Read the linked list from the first node to the last. Which is linked to the NULL.
Definition: list.c:56
void interact_scanf(void)
Definition: list.c:239
int get_flag2null(node *terminal_node)
Get the flag to reach NULL. The index is returned to get the node->ngb[index] = NULL.
Definition: list.c:108
void migrate(list *src, list *dst)
Definition: list.c:200
int enter(list *, int log)
Insert new element.
Definition: list.c:164
Definition: list.h:24
Definition: list.h:29