DUE: Tuesday 5/19
January 1, 2002 May 18, 2009 December 9, 2008
DUE: Thursday 5/21
DUE: Wednesday 5/27
DUE: Wednesday 6/3
template <class T> bool operator== ( const Vec<T>& left, const Vec<T>& right );
DUE: Tuesday 6/9
In this lab, we'll focus on the list class of the standard library, as well as iterators. Remember that iterators are essentially pointers.
In this lab, iterators must be used; the [] operator is not allowed.
template <class T>
ostream& operator<< ( ostream& os, const list<T>& l )
{
typename list<T>::const_iterator i = l.begin();
// ...
}
void small_sort( vector<double>& v )
{
int n = v.size();
for( int i = 0 ; i < n - 1 ; i++ )
{
// Find index of next smallest value
int small_index = i;
for ( int j = i + 1 ; j < n ; j++ )
{
if ( v[j] < v[small_index] ) {
small_index = j;
}
}
// Swap next smallest into place
double temp = v[i];
v[i] = v[small_index];
v[small_index] = temp;
}
}
DUE: Thursday 6/11
In this lab, we'll focus on the map class of the standard library, as well as iterators. As with the previous lab, remember that iterators are essentially pointers.
In the steps that follow, you'll extend the word-count program we did in class to keep track of where each word appears in the given input stream.
int main( int argc, char* argv[] )
{
map< string, vector<int> > words;
Enter the search word (single word only): Achilles The word "Achilles" appears 6 times as follows. It's word #18 It's word #218 It's word #303 It's word #384 It's word #489 It's word #555 Enter the search word (single word only): computer The word "computer" does not appear in the input file. Enter the search word (single word only): ...
DUE: Wednesday 6/17
DUE: Monday 6/22