STL Overview

there are some example programs in the lecture section.. leftmost column of calendar
there is one on using the Vector and List.  
Video Overview



there will be 2 parts to this lab assignment
Create an example of use of the STD container Vector (main1.cpp)
Create an example of use of the STD container List (main2.cpp)


here are some resources that might help you
Containers General Info
std::vector reference
std::list reference
std::algorithm reference


Details:
For both parts you will use the size , push_back , end, begin, rend and rbegin functions
for part one you will also use the overloaded [] operator, it is not available for the list

Part 1, std::vector
create the file main1.cpp
it should match the optput of 'example1'


Part 2, std::list
create the file main2.cpp
you will use a std:List not a vector in this example
it should match the optput of 'example2'
run 'example2' to see what it is supposed to do 


File: example1_output.txt 

creating an integer vector
adding values to the vector
adding value 10 
adding value 20 
adding value 30 
adding value 40 
adding value 50 
call the size function 
size returns 5


creating a standard vector::iterator
setting the iterator = to vector.begin()
our iterator points to the value 10
incrementing the iterator
our iterator now points to the value 20


printing the items in the vector front to back
set our iterator to vector.begin()  and use a while loop ( != vector.end() )
   the iterator now points to 10
   increment the iterator 
   the iterator now points to 20
   increment the iterator 
   the iterator now points to 30
   increment the iterator 
   the iterator now points to 40
   increment the iterator 
   the iterator now points to 50
   increment the iterator 

Vector also has an overloaded [] operator 
use a for loop and print out the elements of the vector via the index operator
myIntegerVector[0] = 10
myIntegerVector[1] = 20
myIntegerVector[2] = 30
myIntegerVector[3] = 40
myIntegerVector[4] = 50
use the std::random_shuffle( iterator start, iterator end)  algorithm to randomize the values in the vector (be sure to seed the random number generator) 
use a for loop and print out the elements of the vector via the index operator
myIntegerVector[0] = 50
myIntegerVector[1] = 40
myIntegerVector[2] = 20
myIntegerVector[3] = 10
myIntegerVector[4] = 30
use the sort algorithm to sort the vector 
use a for loop and print out the elements of the vector via the index operator
myIntegerVector[0] = 10
myIntegerVector[1] = 20
myIntegerVector[2] = 30
myIntegerVector[3] = 40
myIntegerVector[4] = 50



File: example2_output.txt

creating a string list
adding values to the list
adding value one 
adding value two 
adding value three 
adding value four 
adding value five 


creating an iterator
setting the iterator = to list.begin()
our iterator points to the value one
incrementing the iterator
our iterator now points to the value two


printing the items in the list front to back
   the iterator now points to one
   increment the iterator 
   the iterator now points to two
   increment the iterator 
   the iterator now points to three
   increment the iterator 
   the iterator now points to four
   increment the iterator 
   the iterator now points to five
   increment the iterator 


create a reverse_iterator
printing the items in the list back to front
set our iterator to list.rbegin()  and use a while loop ( != list.rend() )
   the iterator now points to five
   increment the iterator 
   the iterator now points to four
   increment the iterator 
   the iterator now points to three
   increment the iterator 
   the iterator now points to two
   increment the iterator 
   the iterator now points to one
   increment the iterator 

using the provided function void PrintBackwards(string val)
 use the for_each function to call it with
 all the values in list 
FORMAT: for_each( iterator start, iterator end , function name)

eno
owt
eerht
ruof
evif