#include <iostream>
using namespace std;
class Node
{
private:
int data; // different data type for other apps
Node *next; // the link pointer to next item
public:
Node(int x=0,Node * ptr=NULL){data=x;}// constructor 构造函数
int getData( );
Node *getNext( );
void setData(int x);
void setNext(Node *ptr);
};
int Node::getData()
{
return data;
}
Node* Node::getNext()
{
return next;
}
void Node::setData(int x)
{
data = x;
}
void Node::setNext(Node* ptr)
{
next = ptr;
}
class List {
private:
Node *head_ptr; Node *tail_ptr; int numOfItems;
public:
List( );
void initial(int a[], int n);//创建一个链表
// constructor
int size( ); Node *getHead( ); Node *getTail( );
bool isEmpty( );
Node *search(int x);
//Node *itemAt(int position);
void removeHead();
void removeTail();
void remove(int x); // delete leftmost item having x
void insertHead(int x);
void insertTail(int x);
void insert( int x,int y);
};
List::List()
{
tail_ptr = NULL;
numOfItems = 0;
}