📄 list.h
字号:
// List.h: interface for the List class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_LIST_H__C59685F0_2F21_4084_A072_D86EB4E57559__INCLUDED_)
#define AFX_LIST_H__C59685F0_2F21_4084_A072_D86EB4E57559__INCLUDED_
class tzObject;
//##ModelId=42E494EE03AB
typedef struct listnode ListNode;
//##ModelId=42E494EE03B9
struct listnode
{
//##ModelId=42E494EE03D9
tzObject *object;
//##ModelId=42E494EE03E0
struct listnode *next;
//##ModelId=42E494EF0003
struct listnode *prev;
};
//##ModelId=42E494EF001F
class List
{
public:
//
// Constructor/Destructor
//
//##ModelId=42E494EF0020
List();
//##ModelId=42E494EF002E
~List();
//
// add() will append an Object to the end of the list
//
//##ModelId=42E494EF002F
void add(tzObject *);
//
// 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.
//
//##ModelId=42E494EF003E
void add(int position, tzObject *object);
//
// append the objects in a list to this list
//##ModelId=42E494EF0041
void add(List *plist);
//
// clear() will set the list to empty. This call will
// DELETE objects that were in the list before this call.
//
//##ModelId=42E494EF004F
void clear();
//
// Deep copy member function
//
//##ModelId=42E494EF0050
List *clone();
//
// Direct access to list items. This can only be used to retrieve
// objects from the list.
//
//##ModelId=42E494EF0051
tzObject *get(int index);
//
// Get the index number of an object. If the object is not found,
// returnes -1
//
//##ModelId=42E494EF005E
int indexOf(tzObject *);
//
// Remove the object at the given position.
//
//##ModelId=42E494EF0060
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.
//
//##ModelId=42E494EF006E
void remove(tzObject *);
//
// Remove the node from the list, should set the current pointer.
//
//##ModelId=42E494EF0070
void remove(ListNode *node);
//
// Access to the number of elements
//
//##ModelId=42E494EF0072
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...)
//
//##ModelId=42E494EF007D
void set(int position, tzObject *object);
//##ModelId=42E494EF0080
void dump();
private:
//
// Pointers into the list
//
//##ModelId=42E494EF008D
listnode *head;
//##ModelId=42E494EF0092
listnode *tail;
//
// For list traversal it is nice to know where we are...
//
//##ModelId=42E494EF009D
ListNode *current;
//##ModelId=42E494EF00AB
int current_index;
//
// Its nice to keep track of how many things we contain...
//
//##ModelId=42E494EF00DA
int number;
};
#endif // !defined(AFX_LIST_H__C59685F0_2F21_4084_A072_D86EB4E57559__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -