帮忙看一下双向链表?
我有一个 LinkedList 类,它有一个名为 Node 的类
class Node {
public:
Node() { next = NULL; prev = NULL; }
~Node() {}
public :
Node *next;
Node *prev;
T data;
};
在同一个 LinkedList 类中,我有以下函数定义,因为它全部在头文件中
public:
LinkedList();
~LinkedList();
// methods -- note that the return values are of type T. Don't return a Node!
void append(T item);
T get(int idx);
void insert(int idx, T item);
void map(T (*pf)(T item));
T remove(int index);
int size();
void unshift(T item);
不,我首先尝试实现操作,
我需要返回一个新的空 Linked列表。
请帮助,我尝试了很多事情,
会像这样简单吗
LinkedList<T>::LinkedList() {
head = NULL;
current = NULL;
}
I have a class LinkedList clas that has a class called Node
class Node {
public:
Node() { next = NULL; prev = NULL; }
~Node() {}
public :
Node *next;
Node *prev;
T data;
};
In the same LinkedList class i have the following function defininitions, because it is all in a header file
public:
LinkedList();
~LinkedList();
// methods -- note that the return values are of type T. Don't return a Node!
void append(T item);
T get(int idx);
void insert(int idx, T item);
void map(T (*pf)(T item));
T remove(int index);
int size();
void unshift(T item);
No I am trying to implement the operations
first i need to return a new, empty Linked List.
please help, i tried many things
would it be as simple as
LinkedList<T>::LinkedList() {
head = NULL;
current = NULL;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
会这么简单吗?
是的。
Would it be as simple as?
Yes.