Merger - list<int>::iterator current1 =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <list> using namespace std; /** * Given two distinct lists, each of which are assumed to be sorted in * non-decreasing order, this function mutates the primary list so as * to include all elements of the secondary list while maintaining the * non-decreasing invariant. */
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: list<int>::iterator current1 = primary.begin(); for (list<int>::const_iterator current2 = secondary.begin(); current2 != secondary.end(); current2++){ if (*current1<=*current2){ current1++; primary.insert(current1, *current2); } else primary.insert(current1, *current2); } }...
View Full Document

This note was uploaded on 05/03/2011 for the course CSCI 180 taught by Professor Goldwasser,m during the Fall '08 term at Saint Louis.

Ask a homework question - tutors are online