template <class type> void Tqueue<type>::insertBefore(type data){ if(_curr){ Tqnode<type>* temp= new Tqnode<type>(data,_curr->_prev, _curr); if(temp->_prev) temp->_prev->_next = temp; _curr->_prev = temp; _curr=temp; }else{ Tqnode<type>* temp= new Tqnode<type>(data); _curr = _head = _tail = temp; } } template <class type> void Tqueue<type>::insertAfter(type data){ if(_curr){ Tqnode<type>* temp= new Tqnode<type>(data,_curr, _curr->_next); if(temp->_next) temp->_next->_prev = temp; _curr->_next = temp; _curr=temp; }else{ Tqnode<type>* temp= new Tqnode<type>(data); _curr = _head = _tail = temp; } }
Tuesday, 20 March 2012
insertBefore and insertAfter functions
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment