


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



template <class Key, class Compare = less
for (set
pair<iterator,bool> set
Inserts the entry into the set and returns a pair. The first component of the pair refers to the location in the set containing the entry. The second component is true if the entry wasn’t already in the set and therefore was inserted. It is false otherwise.
iterator set
This also inserts the key if it is not already there. The iterator pos is a “hint” as to where to put it. This makes the insert faster if the hint is good.
size_type set
(where size type is generally equivalent to an unsigned int).
Write a function to count the number of times a given first name appears in a set of names. Here is the prototype:
int count_first(const string& fname, const set
Here is the Name class from Lecture 14:
class Name { public: Name(const string& first, const string& last) : first_(first), last_(last) {} const string& first() const { return first_; } const string& last() const { return last_; } private: string first_; string last_; };
bool operator< (const Name& left, const Name& right) { return left.last() < right.last() || (left.last() == right.last() && left.first() < right.first()); }
bool operator== (const Name& left, const Name& right) { return left.last() == right.last() && left.first() == right.first(); }
Let’s design a program to simulate Conway’s Game of Life. Initially, due to time constraints, we will focus on the main data structures of needed to solve the problem.
Here is an overview of the Game:
http://www.math.com/students/wonders/life/life.html http://www.radicaleye.com/lifepage/patterns/contents.html http://www.bitstorm.org/gameoflife/
In class we will brainstorm about how to write a simulation of the Game of Life, focusing on the representation of the grid and on the actual birth and death processes.
We have already been working toward understanding the requirements. This effort includes playing with small examples by hand to understand the nature of the game, and a preliminary outline of the major issues.