template <class T>
boolean List<T>::Delete(T x)
{
Node<T> *temp;
if (Empty())
return FALSE;
if (head->val == x){
temp = head->next;
delete head;
size--;
head = temp;
return TRUE;
}
for (Node<T> *p = temp = head; p; temp = p, p = p->next)
if (p->val == x){
temp->next = p->next;
delete p;
size--;
return TRUE;
}
return FALSE;
}
template <class T>
boolean List<T>::Contains(T x)
{
for (Node<T> *p = head; p; p = p->next)
if (p->val == x)
return TRUE;
return FALSE;
}
template <class T>
void List<T>::Print()
{
for (Node<T> *p = head; p ; p = p->next)
cout << p->val << " ";
cout << "\n";
}
void main()
{
List<int> intlist;
int i;
for (i = 0; i < 10; i++)
intlist.Insert(i);
intlist.Print();
intlist.Delete(1);
intlist.Delete(2);
intlist.Print();