MCPcopy Create free account
hub / github.com/YatSenOS/YatSenOS-Tutorial-Volume-1 / List

Class List

lab5/src/4/include/list.h:10–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8};
9
10class List
11{
12public:
13 ListItem head;
14
15public:
16 // 初始化List
17 List();
18 // 显式初始化List
19 void initialize();
20 // 返回List元素个数
21 int size();
22 // 返回List是否为空
23 bool empty();
24 // 返回指向List最后一个元素的指针
25 // 若没有,则返回nullptr
26 ListItem *back();
27 // 将一个元素加入到List的结尾
28 void push_back(ListItem *itemPtr);
29 // 删除List最后一个元素
30 void pop_back();
31 // 返回指向List第一个元素的指针
32 // 若没有,则返回nullptr
33 ListItem *front();
34 // 将一个元素加入到List的头部
35 void push_front(ListItem *itemPtr);
36 // 删除List第一个元素
37 void pop_front();
38 // 将一个元素插入到pos的位置处
39 void insert(int pos, ListItem *itemPtr);
40 // 删除pos位置处的元素
41 void erase(int pos);
42 void erase(ListItem *itemPtr);
43 // 返回指向pos位置处的元素的指针
44 ListItem *at(int pos);
45 // 返回给定元素在List中的序号
46 int find(ListItem *itemPtr);
47};
48
49#endif

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected