0

I am working on a set class and I have successfully written an insert function, but I need the function to insert in an ordered fashion.

```
bool Set::insert( const EType & A )
{
bool Flag = false;
unsigned Position = 0;
Node * Prev = Head;
Node * Curr = Head->Succ;
Node * Temp;
Temp = new Node;
if (Temp != NULL )
{
Temp->Item = A;
Temp->Succ = Curr;
Prev->Succ = Temp;
Num++;
Flag = true;
}
return Flag;
}
```

```
Set::Set()
{
Num = 0;
Head = new (nothrow) Node;
Head->Succ = NULL;
}
```

```
class Set
{
private:
struct Node
{
EType Item; // User data item
Node * Succ; // Link to the node's successor
};
unsigned Num; // Number of user data items in the set
Node * Head; // Link to the head of the chain
```

Tell me if anything else is needed