homework simply remove

template<class List_entry>
Error_code List<List_entry>::remove(int position,List_entry&x)
{
 Node<List_entry>*prior,*current;
 if(count==0)return fail;
 if(position<0||position>=count)return range_error;
 if(position>0)
 {
  prior=set_position(position-1);
  current=prior->next;
  prior->next=current->next;
 }
 else
 {
  current=head;
  head=head->next;
 }
 x=current->entry;
 delete current;
 count--;
 return success;
}

posted @ 2013-09-26 13:00  刘颖斌  阅读(115)  评论(0)    收藏  举报