-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStandardLinkedList.h
More file actions
52 lines (44 loc) · 1.38 KB
/
StandardLinkedList.h
File metadata and controls
52 lines (44 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* StandardLinkedList.h
* This module implements a standard linked list, with int nodes.
*/
#ifndef STANDARDLINKEDLIST_H_
#define STANDARDLINKEDLIST_H_
/*
* This struct represents a single move in the board, to support redo, undo and reset.
* If continueForward == 1, the next move should also be executed if a single redo opeartion
* was performed on the relveant move (for autofill and generate), i.e. the move is part of
* a sequence of moves that belong to the same redo/undo operation. Same for continueBackward.
*/
typedef struct snode {
int val;
int varIndex;
struct snode *next;
} StandardNode;
/*
* This struct represents a doubly-linked list, to support redo, undo, and reset commands.
* Head is the first node in the list.
*/
typedef struct {
StandardNode *Head;
StandardNode *Tail;
} StandardList;
/*
* Initializes a new list.
*/
StandardList* createNewStandardList();
/*
* Adds a new move to the list (with function parameters as its values).
* Any move beyond CurrentMove is removed.
*/
void addNewStandardMove(StandardList* l, int val, int varIndex);
/*
* Searchs for val in the list.
* If val is found in a StandardNode, returns it's varIndex. Otherwise, returns -2.
*/
int lookupInStandardList(StandardList* L, int val);
/*
* Destroys a list and free all its memory resources.
*/
void destroyStandardList(StandardList* L);
#endif /* STANDARDLINKEDLIST_H_ */