单链的remove

来源:互联网 发布:如何开网络主播公司 编辑:程序博客网 时间:2024/06/05 10:46
template<class List_entry>
Error_code List<List_entry>::insert(int position,List entry_&x)
{
 if(position<0||position>count)
  return range_error;
 Node<List_entry>*new_node,*previous,*following;
 if(position>0)
 {
  previous=set_position(position-1);
  following=previous->next;
 }
 else following=head;
 new_node=new Node<List_entry>(x,previous);
 if(new_code==NULL)
  return underflow;
 if(position==0)
  head=following;
 else
  previous->next=following->next;
 count--;
 return success;
}