list.h
来自「数据结构与程序设计教材源码 数据结构与程序设计教材源码」· C头文件 代码 · 共 57 行
H
57 行
template <class Node_entry>
struct Node {
// data members
Node_entry entry;
Node<Node_entry> *next;
Node<Node_entry> *back;
// constructors
Node();
Node(Node_entry, Node<Node_entry> *link_back = NULL,
Node<Node_entry> *link_next = NULL);
};
template <class List_entry>
class List {
public:
List();
int size() const;
bool full() const;
bool empty() const;
void clear();
void traverse(void (*visit)(List_entry &));
Error_code retrieve(int position, List_entry &x) const;
Error_code replace(int position, const List_entry &x);
Error_code remove(int position, List_entry &x);
Error_code insert(int position, const List_entry &x);
~List();
List(const List<List_entry> ©);
void operator =(const List<List_entry> ©);
// Add specifications for methods of the list ADT.
// Add methods to replace compiler generated defaults.
protected:
// Data members for the doubly-linked list implementation follow:
int count;
mutable int current_position;
mutable Node<List_entry> *current;
// The auxiliary function to locate list positions follows:
void set_position(int position) const;
};
template <class List_entry>
Node<List_entry>::Node()
{
next = back = NULL;
}
template <class List_entry>
Node<List_entry>::Node (List_entry data, Node<List_entry> *link_back = NULL,
Node<List_entry> *link_next = NULL)
{
entry = data;
back = link_back;
next = link_next;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?