-
Book Overview & Buying
-
Table Of Contents
C++ STL Cookbook - Second Edition
By :
An ordered task list (or a ToDo list) is a common computing application. Formally stated, it's a list of tasks associated with a priority, sorted in reverse numerical order.
You may be tempted to use a priority_queue for this, because as the name implies, it's already sorted in priority (reverse numerical) order. The disadvantage of a priority_queue is that it has no iterators, so it's difficult to operate upon individual elements without pushing and popping items to and from the queue.
For this recipe, we'll use a multimap for the ordered list. The multimap is an associative container which keeps items in order, and it can be accessed using reverse iterators for the proper sort order.
This is a short and simple recipe that initializes a multimap and prints it in reverse order.
multimap:
using todomap = multimap<int, string>;
...