您的位置:首页 > 其它

哪位大神能帮帮我编写下双向链表这个程序

2014-05-28 20:56 246 查看
我是大一的,先修大二课程C++,可这个双向链表程序太难了,有的知识我根本没学过,三天就要交上去,求助攻啊

以下是要求:

题目:双向链表的实现

要求

链表元素中要有指针指向动态分配的内存空间,练习析构函数的操作规则

链表应该至少有两个类,Node类和List类, Node类的构造和析构函数负责结点本身的初始化和空间回收,List类负责整个链表的管理工作,其构造和析构函数负责整个链表的初始化和回收

从List类派生出Stack和Queue,并使其具有自身的操作特性,练习派生类的概念

从List类派生出Set类,负责集合操作的实现

要求:具有差“—”,并”+”union,交and三种操作,其中前两个是运算符的重载,第三个并非运算符的重载

练习要点:理解并、交、差操作并不影响参与操作的集合,实现并交差操作

构造函数:

CList:Constructs an empty ordered list.

获得头/尾指针

GetHead:Returns the head element of the list

GetTail:Returns the tail element of the list

链表元素操作

RemoveHead :Removes the element from the head of the list.

RemoveTail :Removes the element from the tail of the list.

AddHead :Adds an element (or all the elements in another list) to the head of the list (makes a new head). 函数重载

AddTail :Adds an element (or all the elements in another list) to the tail of the list (makes a new tail). 函数重载

RemoveAll : Removes all the elements from this list.

Operator+() 运算符重载函数

遍历操作

GetNext Gets the next element for iterating.

GetPrevGets the previous element for iterating.

检索/修改操作

GetAt Gets the element at a given position.

SetAt Sets the element at a given position.

RemoveAt Removes an element from this list, specified by position.

插入操作

InsertBefore:Inserts a new element before a given position.

InsertAfter:Inserts a new element after a given position.

查询操作

Find:Gets the position of an element specified by pointer value.

FindIndex:Gets the position of an element specified by a zero-based index.

状态测试

GetCount:Returns the number of elements in this list.

IsEmpty:Tests for the empty list condition (no elements).
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐