LinkedList.cpp
// Iterative version of clone.
// This version walks down the linked structure making a
//   new Node for each double in the structure.
Iterative version of clone.
This version walks down the linked structure making a
new Node for each double in the structure.
Iterative version of clone . This version walks down the linked structure making a new Node for each double in the structure .
Node * List::clone(Node * ptr)
{
	if (ptr == NULL)
	{
		return NULL;
	}
	Node * first = new Node(ptr->entry_);
	Node * last = first;
	ptr = ptr->next_;
	while (ptr != NULL)
	{
		last->next_ = new Node(ptr->entry_);
		last = last->next_;
		ptr = ptr->next_;
	}
	return first;
}
Node * List :: clone ( Node * ptr ) { if ( ptr == NULL ) { return NULL ; } Node * first = new Node ( ptr -> entry_ ) ; Node * last = first ; ptr = ptr -> next_ ; while ( ptr != NULL ) { last -> next_ = new Node ( ptr -> entry_ ) ; last = last -> next_ ; ptr = ptr -> next_ ; } return first ; }
Iterative version of clone.
Iterative version of clone .