Homework/HW02/List.cc
void List::concatenate(List &data)
{
    if (head != data.head) // if the two lists are not the same
    {
        if (head) // if the first list is not empty
        {
            // call the ListNode function to add the second list 
            // to the tail of the first
            tail->concatenate(data.head); 
            size += data.size; // we also have to update the size
            if (data.tail)     // and the tail
                tail = data.tail;
        }
        else // if the first list is empty
        {
            // move the list from the second one into it
            head = data.head;
            size = data.size;
            tail = data.tail;
        }
        if (data) // if the second list was not empty, unlink/empty it
        {
            data.size = 0;
            data.head=NULL;
            data.tail=NULL;
        }
    }
    else // error
        cout << "Attepmt to concatenate a list to itself. "
             << "Operation ignored." << endl;
}
// Concatenates the second list to the first and empties the second
// list.
Concatenates the second list to the first and empties the second
list.
Concatenates the second list to the first and empties the second list .
void List::concatenate(List &data)
{
    if (head != data.head) 
    {
        if (head) 
        {
            tail->concatenate(data.head); 
            size += data.size; 
            if (data.tail)     
                tail = data.tail;
        }
        else 
        {
            head = data.head;
            size = data.size;
            tail = data.tail;
        }
        if (data) 
        {
            data.size = 0;
            data.head=NULL;
            data.tail=NULL;
        }
    }
    else 
        cout << "Attepmt to concatenate a list to itself. "
             << "Operation ignored." << endl;
}
void List :: concatenate ( List & data ) { if ( head != data . head ) { if ( head ) { tail -> concatenate ( data . head ) ; size += data . size ; if ( data . tail ) tail = data . tail ; } else { head = data . head ; size = data . size ; tail = data . tail ; } if ( data ) { data . size = 0 ; data . head = NULL ; data . tail = NULL ; } } else cout << " " << " " << endl ; }
Concatenates the second list to the first and empties the second
list.
Concatenates the second list to the first and empties the second list .
// if the two lists are not the same // if the first list is not empty // call the ListNode function to add the second list  // to the tail of the first // we also have to update the size // and the tail // if the first list is empty // move the list from the second one into it // if the second list was not empty, unlink/empty it // error