-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathList.h
More file actions
82 lines (64 loc) · 1.45 KB
/
List.h
File metadata and controls
82 lines (64 loc) · 1.45 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
WeChat: cstutorcs
QQ: 749389476
Email: tutorcs@163.com
// Interface to the String List ADT
// !!! DO NOT MODIFY THIS FILE !!!
#ifndef LIST_H
#define LIST_H
#include <stdbool.h>
typedef struct list *List;
/**
* Creates a new empty list
* Time complexity: O(1)
*/
List ListNew(void);
/**
* Frees all memory allocated to the given list
* Time complexity: O(n)
*/
void ListFree(List l);
/**
* Adds a copy of the given string to the end of the list
* Time complexity: O(1)
*/
void ListAppend(List l, char *s);
/**
* Returns the number of items in the list
* Time complexity: O(1)
*/
int ListSize(List l);
/**
* Sorts the list in ASCII order
* Time complexity: O(n log n)
*/
void ListSort(List l);
/**
* Prints the list to stdout, one string per line
* If the strings themselves contain newlines, too bad
* Time complexity: O(n)
*/
void ListPrint(List l);
////////////////////////////////////////////////////////////////////////
// Do NOT use these functions
typedef struct listIterator *ListIterator;
/**
* Creates an iterator for the given list
* Time complexity: O(1)
*/
ListIterator ListItNew(List l);
/**
* Gets the next item in the list. The item should not be modified.
* Time complexity: O(1)
*/
char *ListItNext(ListIterator it);
/**
* Checks if the list has a next item
* Time complexity: O(1)
*/
bool ListItHasNext(ListIterator it);
/**
* Frees the given iterator
* Time complexity: O(1)
*/
void ListItFree(ListIterator it);
#endif