#ifndef SORTEDCHAIN_INCLUDED
#define SORTEDCHAIN_INCLUDED
#include
#include
using namespace std;
template
struct ChainNode
{ E data;
ChainNode* link;
ChainNode(): link(NULL){};
ChainNode(E& e1, ChainNode* next = NULL): data(e1), link(next) {}
};
template
class SortedChain
{
public:
SortedChain()
{ first = new ChainNode;
assert(first != NULL);
}
~SortedChain(){delete first;};
void Insert(const K k1, E& e1);
LinkedSet& operator + (LinkedSet& s2);
private:
ChainNode* first;
};
template
void SortedChain::Insert(const K k1, E& e1)
{ ChainNode* p = first->link, * pre = first, * newNode;
while (p != NULL && p->data < k1)
{ pre = p; p = p->link;
}
if( p != NULL && p->data == k1)
{p->data = e1; return;}
newNode = new ChainNode(e1);
if (newNode == NULL) {cout<<"memeory assign failed"<
newNode->link = p; pre->link = newNode;
}
template
LinkedSet& LinkedSet::operator + (LinkedSet& s2)
{
}
#endif // SORTEDCHAIN_INCLUDED
#include
#include
#include "SortedChain"
int main()
{
SortedChain l1, l2;
return 0;
}