Simply Linked Implementation remove函数

来源:互联网 发布:人工智能虚拟系统 编辑:程序博客网 时间:2024/06/06 15:39

SimplyLinked Implementation

Template<classList_entry>

Error_codeList <List_entry>::remove(int position,const List_entry &x)

{

If(position<0||position>count)

Returnrange_error;

 

 

Node<List_entry>*new_node,*previous,*following;

If(position>0)

{

previous=set_position(position-1);

previous=following->next//Following=previous->next;

}

//Elsefollowing =head;

//New_code=newNode<List_entry>(x,following);

If(new_node==NULL)

Return underflow;//overflow;

If(position==0)

Head=N//Head=new_node;

Else

Previous->next=new_node;

Count--;

Returnsuccess;

 

}