template <class Type> int Setlist<type>:: Delmember( const Type &x)t SetNode<type> p=first-link, *g=first while(p!= NULL && p-data<x) {q=p;p=p→+limk;} if (p =nULL & p-data ==x)t g-link=p→link; if(p==last last=g; delete p; return 1 else return o
template <class Type> int SetList<Type> :: DelMember ( const Type & x ) { SetNode<Type> *p = first→link, *q = first; while ( p != NULL && p→data < x ) { q = p; p = p→link; } if ( p != NULL && p→data == x ) { q→link = p→link; if ( p == last ) last = q; delete p; return 1; } else return 0; }
用有序链表表示集合时的几个重载函数 template <class Type> Setlist<type>& setlist <type>:: operator=( Setlist<type>& right)( SetNode<type>ipb=right first-link SetNode<type> xpa=first new SetNode<Type>; while(pb!=NULL)( pa→link= new setnode<lype>(pb→data); pa=p→link;pb=pb→link; pa-link- NULL; last=pa return *this:
用有序链表表示集合时的几个重载函数 template <class Type> SetList<Type>& SetList <Type> :: operator = ( SetList<Type> & right ) { SetNode<Type>*pb = right.first→link; SetNode<Type>*pa = first = new SetNode<Type>; while ( pb != NULL ) { pa→link = new SetNode<Type> (pb→data); pa = pa→link; pb = pb→link; } pa→link = NULL; last = pa; return *this; }
template <class type> Setlist< Type>& setlist<type>:: operator + SetList<Type>& right)i SetNode<Type> pb=right first-link SetNode<type> xpa=first; SetNode<type> pc=first while(pa!=nULL & pb=NULL& if( pa-data==pb-data) pc→→link=pa;p=pa-link; pb=pb-link;) else if(pa→data<pb→→data) Lpc-link- pa; pa=pa-link;) else
template <class Type> SetList<Type>& SetList<Type> :: operator + ( SetList<Type> & right ) { SetNode<Type> *pb = right.first→link; SetNode<Type> *pa = first→link; SetNode<Type> *pc = first; while ( pa != NULL && pb != NULL ) { if ( pa→data == pb→data ) { pc→link = pa; pa = pa→link; pb = pb→link;} else if ( pa→data < pb→data ) { pc→link = pa; pa = pa→link;} else
{pc→link= new setnode<lype>(pb→)daa); pb=pb-link; y pC=pC→link; if(pa!=NULL)pc-link- pa; else i while(pb =null)( pc→+link= new methode<ype>(pb→data); pc=p→link;pb=pb→→link; pclink- NULL; last=pc, return this;
{ pc→link = new SetNode<Type> (pb→data); pb = pb→link;} pc = pc→link; } if ( pa != NULL ) pc→link = pa; else { while ( pb != NULL ) { pc→link = new SetNode<Type> (pb→data); pc = pc→link; pb = pb→link; } pc→link = NULL; last = pc; } return *this; }
template <class Type> Setlist<type>& setlist<type>:: operator*( SetList< Type> right)( SetNode<Type> ipb= right first-link SetNode<Type> pa= first-link; SetNode<type> ipc= first while(pa! =NULL &&pb!=NULL)( if(pa→→daa==pb-aata) {pC=pc→link;pa=pa→lnk; pb=pb-link;) else if ( pa-data< pb-data {pc→link=pa→link; delete pa; pa=pc→→link;} else pb=pb→link;
template <class Type> SetList<Type>& SetList<Type>:: operator * ( SetList<Type> & right ) { SetNode<Type> *pb = right.first→link; SetNode<Type> *pa = first→link; SetNode<Type> *pc = first; while ( pa != NULL && pb != NULL ) { if ( pa→data == pb→data ) { pc = pc→link; pa = pa→link; pb = pb→link;} else if ( pa→data < pb→data ) { pc→link = pa→link; delete pa; pa = pc→link; } else pb = pb→link; }