📄 list.h
字号:
class items;
typedef struct listnode ListNode;
struct listnode{
items *item;
struct listnode *pre;
struct listnode *next;
};
class list
{
public:
list();
~list();
void add(items *);
// add() will insert an object at the given position. If the
// position is larger than the number of objects in the list, the
// object is appended; no new objects are created between the end
// of the list and the given position.
//
void add(int position, items *item);
// append the objects in a list to this list
void add(list *plist);
// clear() will set the list to empty. This call will
// DELETE objects that were in the list before this call.
//
void clear();
//
// Deep copy member function
//
list *clone();
//
// Direct access to list items. This can only be used to retrieve
// objects from the list.
//
items *get(int index);
//
// Get the index number of an object. If the object is not found,
// returnes -1
//
int indexOf(items *);
//
// Remove the object at the given position.
//
void remove(int position);
//
// Find the given object in the list and remove it from the list.
// The object will NOT be deleted. If the object is not found,
// NOTOK will be returned, else OK.
//
void remove(items *);
//
// Remove the node from the list, should set the current pointer.
//
void remove(ListNode *node);
//
// Access to the number of elements
//
int size() {return number;}
//
// set() will replace the object already at the given position
// with the new object. If there is no object at the position,the
// list is extended with nil objects until the position is reached
// and then the given object is put there. (This really makes the
// List analogous to a dynamic array...)
//
void set(int position,items *item);
void dump();
private:
//
// Pointers into the list
//
ListNode *head;
ListNode *tail;
//
// For list traversal it is nice to know where we are...
//
ListNode *current;
int current_index;
//
// Its nice to keep track of how many things we contain...
//
int number;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -