Recent Posts
None | 7 sec ago
None | 15 sec ago
None | 22 sec ago
PHP | 22 sec ago
None | 49 sec ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
By Anonymous on the 9th of Feb 2010 09:29:48 PM
Download |
Raw |
Embed |
Report
template<class T>
SAList<T>::SAList(const SAList<T> &right)
{
Node<T> *current;
Node<T> *previous;
head = new Node<T>(right.head->data_);
current = right.head->next_;
while(current != NULL) {
Node<T>* temp = new Node<T>(current->data_);
if(head->next_ == NULL){
head->next_ = temp;
temp->prev_ = head;
previous = temp;
}
else{
temp->prev_ = previous;
previous->next_ = temp;
previous = temp;
}
current = current->next_;
}
}
template <class T>
SAList<T>& SAList<T>::operator= (SAList<T> &right){
Node<T> *cur;
Node<T> *temp;
Node<T> *add;
cur = right.head;
while(cur != NULL)
{
add=new Node<T>(cur->data_);
if(this->head==NULL)
{
head = add;
add->prev_ = tail;
cur = cur->next_;
temp = head;
}
else
{
// if(cur->next_==right.tail)
{
temp->next_=add;
add->prev_=temp;
tail=temp;
temp=temp->next_;
cur=cur->next_;
}
if(temp->next_==NULL)
{
temp->next_=add;
add->prev_=temp;
temp=temp->next_;
cur=cur->next_;
}
}
}
return *this;
}
Submit a correction or amendment below.
Make A New Post