This project's aim is to implement a doubly circular linked list with a sentinel along with some basic operations
Note
This is the first homework of data structures and algorithms from UNSTPB ACS faculty, CS field, 1st year.
typedef struct TrCell2 {
char data;
struct TrCell2 *next;
struct TrCell2 *prev;
} TRCell2, *TRL2;
typedef struct Train {
TRL2 head;
TRL2 mechanic;
} *TTrain;
- move left/right
It moves the mechanic, which represents the current cell, to one of its adjacent positions.
- insert left/right
It inserts a new cell adjacent to the current mechanic's position and it moves the mechanic accordingly.
Note
If the mechanic is in the first car, it will be displayed an error message
- search left/right
It searches for a certain character from the current position until it reaches the sentinel.
- search
It searches circularly for a certain character from the current position to the right until it resches its left neighbour from the start.
- clear_cell
It clears the contents of the cell and it removes it completely.
- clear_all
It clears all the cells and it restores the train to its initial state.
- switch
It reverts the content of the queue up to that point.
Note
All commands besides SHOW, SHOW_CURRENT and SWITCH are put into a pq.
- show
It shows the content of the entire list with mechanic's character between pipes.
- show_current
It shows the content of the mechanic's cell.
- write
It overwrites the mechanic's cell content aka the current cell or the cell under the cursor.