Class Notes (811,155)
Canada (494,530)
CS 138 (14)
Lecture 6

Data Lecture 6.docx

3 Pages
Unlock Document

University of Waterloo
Computer Science
CS 138
Michael Godfrey

Data Lecture 6 January 24, 2013 Vector Review  Vector is a CONTAINER data structure from C++ STD o Like a C-style array except…  Generic and type-safe  Index bounds checking is possible  Can be resized on-the-fly  Either one element at a time or in chunks o Other STL data structures:  Deque  List  Map  Set  Iterating through a vector o Simple, normal, numerical approach o Abstract, powerful but confusing way w/ STL iterators  Useful vector API o o v.push_back(..) o v[i] o v.pop_back(..) o v.size() o v.front() o v.capacity() o v.back() o v.empty() o v.begin() o v.resize(int) o v.end() o v.reserve(int) int main (...) { vector v; v.push_back ("Reimer"); v.push_back ("Scrivens"); v.push_back ("Luongo"); for (int i=0;i::const_iterator i=v.begin(); i!=v.end();i++) { cout<
More Less

Related notes for CS 138

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.