Game Development Reference
In-Depth Information
Listing 16-14. Catching Exceptions
try
{
ExceptionExample();
}
catch (int errorValue)
{
cout << "Error: " << errorValue << endl;
}
Note
You'll see the
unordered_map
put to practical use in Chapter 21, which covers an
EventManager
class that stores
Event
objects keyed by a unique ID value.
Summary
This chapter has introduced you to STL containers based on binary search trees and the hash maps.
These containers provide alternatives to the other containers, which are of particular benefit when
you are dealing with large sets of data. The
set
and
map
containers are useful when you need to have
data that is regularly iterated over and you need to be in order, but you also need to find individual
elements regularly. The
unordered_set
and
unordered_map
containers are useful when you need to
know that inserting and retrieving values will always take the same length of time to execute and you
do not need the data to be sorted.
The next chapter introduces you to the
stack
and
queue
containers. These containers are more
specialized versions of existing data structures. Stacks can be used to add and remove elements
from the top of the container, whereas queues act in a first in, first out manner.