C Project Template
Classes | Macros | Typedefs | Functions
list.h File Reference

Double linked list. This implementation provides O(1) complexity for reversing. See main page for details. This implementataion sacrifices the speed of reading. It requires the check of the flag to the next node when moving from one node to another. However, HW1 P5 only needs to read the lines once. Noted that the direction of the next node is updated by XOR operation, so this double linked list is also known as XOR double linked list (https://en.wikipedia.org/wiki/XOR_linked_list). More...

#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for list.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _node
 
struct  list
 

Macros

#define MAX_LINES   1010
 
#define MAX_LEN_OPER_STR   100
 

Typedefs

typedef struct _node node
 

Functions

nodeinit_node (int data)
 
list init_list (void)
 
void detach_list (list *line)
 
void kill_node (node *)
 
void kill_list (list *)
 
int PrintList (list *)
 
int printNode (node *nStr)
 
int iter_read (node *)
 Read the linked list from the first node to the last. Which is linked to the NULL. More...
 
int get_flag2node (node *terminal_node)
 
int get_flag2null (node *terminal_node)
 Get the flag to reach NULL. The index is returned to get the node->ngb[index] = NULL. More...
 
int get_flag2dst (node *src, node *dst)
 
int leave (list *)
 
int enter (list *, int log)
 Insert new element. More...
 
void migrate (list *src, list *dst)
 
void interact_scanf (void)
 

Detailed Description

Double linked list. This implementation provides O(1) complexity for reversing. See main page for details. This implementataion sacrifices the speed of reading. It requires the check of the flag to the next node when moving from one node to another. However, HW1 P5 only needs to read the lines once. Noted that the direction of the next node is updated by XOR operation, so this double linked list is also known as XOR double linked list (https://en.wikipedia.org/wiki/XOR_linked_list).

Author
Shao-Ting Chiu
Version
0.1
Date
2021-04-01

Function Documentation

◆ enter()

int enter ( list line,
int  log 
)

Insert new element.

Parameters
lognew data
Returns
int 1 for success adding; -1 as error code

◆ get_flag2node()

int get_flag2node ( node terminal_node)

get the flag point to the node. This function assumes a node is linked to at least one node

◆ get_flag2null()

int get_flag2null ( node terminal_node)

Get the flag to reach NULL. The index is returned to get the node->ngb[index] = NULL.

Parameters
terminal_node
Returns
int 2 for two NULL neigbhors, 0 and 1 for flags.

◆ interact_scanf()

void interact_scanf ( void  )

interface. Use stdin for manipulating the linked lists

◆ iter_read()

int iter_read ( node nStr)

Read the linked list from the first node to the last. Which is linked to the NULL.

Returns
int -1 for error report

◆ leave()

int leave ( list line)

Return 1 if one element is pop; -1 for none

◆ migrate()

void migrate ( list src,
list dst 
)
Parameters
srcsource line
dstdestination line