-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkedlist.h
57 lines (47 loc) · 1.38 KB
/
linkedlist.h
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
53
54
55
56
57
#include <stdbool.h>
#include "value.h"
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
/*
* Create an empty list (a new Value object of type NULL_TYPE).
*/
Value *makeNull();
/*
* Create a nonempty list (a new Value object of type CONS_TYPE).
*/
Value *cons(Value *car, Value *cdr);
/*
* Print a representation of the contents of a linked list.
*/
void display(Value *list);
/*
* Get the car value of a given list.
* (Uses assertions to ensure that this is a legitimate operation.)
*/
Value *car(Value *list);
/*
* Get the cdr value of a given list.
* (Uses assertions to ensure that this is a legitimate operation.)
*/
Value *cdr(Value *list);
/*
* Test if the given value is a NULL_TYPE value.
* (Uses assertions to ensure that this is a legitimate operation.)
*/
bool isNull(Value *value);
/*
* Compute the length of the given list.
* (Uses assertions to ensure that this is a legitimate operation.)
*/
int length(Value *value);
/*
* Create a new linked list whose entries correspond to the given list's
* entries, but in reverse order. The resulting list is a shallow copy of the
* original: that is, stored data within the linked list should NOT be
* duplicated; rather, the new list's (new) CONS_TYPE nodes should point to
* precisely the items in the original list.
*
* (Uses assertions to ensure that this is a legitimate operation.)
*/
Value *reverse(Value *list);
#endif