⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list.h

📁 关联规则发现vc源代码
💻 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;

typedef struct listnode ListNode;
struct listnode
{
    tzObject		*object;
    
    struct listnode	*next;
    struct listnode	*prev;
};



class List
{

public:


    //
    // Constructor/Destructor
    //
    List();
    ~List();


    //
    // add() will append an Object to the end of the list
    //
    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.
    //
    void	add(int position, tzObject *object);

	//
	// 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.
    //
    tzObject *get(int index);

    //
    // Get the index number of an object.  If the object is not found,
    // returnes -1
    //
    int			indexOf(tzObject *);

    //
    // 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(tzObject *);


    //
    // 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, tzObject *object);
    
    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;
};

#endif // !defined(AFX_LIST_H__C59685F0_2F21_4084_A072_D86EB4E57559__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -