Absolute C++ (4th Edition) part 83. KEY BENEFIT: C++ programming concepts and techniques are presented in a straightforward style using understandable language and code. KEY TOPICS: C++ Basics; Flow of Control; Function Basics; Parameters and Overloading; Arrays; Structures and Classes; Constructors; Operator Overloading, Friends, and References; Strings; Pointers and Dynamic Arrays; Separate Compilation and Namespaces; Streams and File I/O; Recursion; Inheritance; Polymorphism and Virtual Functions; Templates; Linked Data Structures; Exception Handling; Standard Template Library; Patterns and UML. MARKET: Useful for both beginning and intermediate C++ programmers. . | 828 Standard Template Library MODIFYING SEQUENCE ALGORITHMS Display contains descriptions of some of the generic functions in the STL that change the contents of a container in some way. Remember that adding or removing an element to or from a container can affect any of the other iterators. There is no guarantee that the iterators will be located at the same element after an addition or deletion unless the container template class makes such a guarantee. Of the template classes we have seen list and slist guarantee that their iterators will not be moved by additions or deletions except of course if the iterator is located at an element that is removed. The template classes vector and deque make no such guarantee. Some of the function templates in Display guarantee the values of some specific iterators you can of course count on those guarantees no matter what the container is. Self-Test Exercises 21. Can you use the random_shuffle template function with a list container 22. Can you use the copy template function with vector containers even though copy requires forward iterators and vector has random-access iterators SET ALGORITHMS Display shows a sample of the generic set operation functions defined in the STL. Note that generic algorithms assume that the containers store their elements in sorted order. The containers set map multiset and multimap do store their elements in sorted order therefore all the functions in Display apply to these four template class containers. Other containers such as vector do not store their elements in sorted order these functions should not be used with such containers. The reason for requiring that the elements be sorted is so that the algorithms can be more efficient. Self-Test Exercises 23. The mathematics course version of a set does not keep its elements in sorted order and it has a union operator. Why does the set_union template function require that the containers keep their elements in sorted order .