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...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Anonymous on the 9th of Feb 2010 09:29:48 PM Download | Raw | Embed | Report
  1. template<class T>
  2. SAList<T>::SAList(const SAList<T> &right)
  3. {
  4.     Node<T> *current;
  5.     Node<T> *previous;
  6.     head = new Node<T>(right.head->data_);
  7.     current = right.head->next_;
  8.     while(current != NULL) {
  9.         Node<T>* temp = new Node<T>(current->data_);
  10.         if(head->next_ == NULL){
  11.             head->next_ = temp;
  12.             temp->prev_ = head;
  13.             previous = temp;
  14.         }
  15.         else{
  16.          temp->prev_ = previous;
  17.          previous->next_ = temp;
  18.          previous = temp;
  19.       }
  20.       current = current->next_;
  21.    }
  22. }
  23.  
  24. template <class T>
  25. SAList<T>& SAList<T>::operator= (SAList<T> &right){
  26.         Node<T> *cur;
  27.         Node<T> *temp;
  28.         Node<T> *add;
  29.  
  30.         cur = right.head;
  31.  
  32.         while(cur != NULL)
  33.         {
  34.                 add=new Node<T>(cur->data_);
  35.  
  36.                 if(this->head==NULL)
  37.                 {
  38.                         head = add;
  39.                         add->prev_ = tail;
  40.                         cur = cur->next_;
  41.                         temp = head;
  42.                 }
  43.                 else
  44.                 {
  45.         //              if(cur->next_==right.tail)
  46.                         {
  47.                                 temp->next_=add;
  48.                                 add->prev_=temp;
  49.                                 tail=temp;
  50.  
  51.                                 temp=temp->next_;
  52.                                 cur=cur->next_;
  53.                         }
  54.  
  55.                         if(temp->next_==NULL)
  56.                         {
  57.                                 temp->next_=add;
  58.                                 add->prev_=temp;
  59.  
  60.                                 temp=temp->next_;
  61.                                 cur=cur->next_;
  62.                         }
  63.                 }
  64.         }
  65.         return *this;
  66. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: