写在前面:
好久没有写博客了,趁着这个周末作业不算太多,好好总结一下这学期学过的的数据结构好了。
话说,,临近学期末了,我才明白,数据结构学下来,所得的成果应该是众多自己写的头文件,,,应该还不晚8,,QAQ
简介:
数组实现的List。
与双链表实现的相比,随机访问效率高,但插入和删除元素的效率低。
因为必须初始化一个大小,所以有溢出风险。
代码:
const int max_list=50;
enum Error_code{
underflow,overflow,success,range_error};
template <class List_entry>
class List{
public:
List();
int size()const;
bool empty()const;
bool full()const;
void clear();
void traverse(void(*visit)(List_entry &));
Error_code insert(int position, const List_entry &x);
Error_code remove(int position, List_entry &x);
Error_code replace(int position, const List_entry &x);
Error_code retrieve