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>
Go to the source code of this file.
|
#define | MAX_LINES 1010 |
|
#define | MAX_LEN_OPER_STR 100 |
|
|
typedef struct _node | node |
|
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
- Copyright
- Copyright (c) 2021
◆ enter()
int enter |
( |
list * |
line, |
|
|
int |
log |
|
) |
| |
Insert new element.
- Parameters
-
- 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
-
- 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()
Return 1 if one element is pop; -1 for none
◆ migrate()
- Parameters
-
src | source line |
dst | destination line |