tailieunhanh - Lecture Programming principles and practice using C++: Chapter 20 - Bjarne Stroustrup
Chapter 20 present the STL – the containers and algorithms part of the C++ standard library. The STL is an extensible framework dealing with data in a C++ program. First, this chapter present the general ideal, then the fundamental concepts, and finally examples of containers and algorithms. | Chapter 20 The STL (containers, iterators, and algorithms) Bjarne Stroustrup Abstract This lecture and the next present the STL – the containers and algorithms part of the C++ standard library The STL is an extensible framework dealing with data in a C++ program. First, I will present the general ideal, then the fundamental concepts, and finally examples of containers and algorithms. The key notions of sequence and iterator used to tie data together with algorithms (for general processing) are also presented. Stroustrup/Programming - Nov'13 Overview Common tasks and ideals Generic programming Containers, algorithms, and iterators The simplest algorithm: find() Parameterization of algorithms find_if() and function objects Sequence containers vector and list Associative containers map, set Standard algorithms copy, sort, Input iterators and output iterators List of useful facilities Headers, algorithms, containers, function objects . | Chapter 20 The STL (containers, iterators, and algorithms) Bjarne Stroustrup Abstract This lecture and the next present the STL – the containers and algorithms part of the C++ standard library The STL is an extensible framework dealing with data in a C++ program. First, I will present the general ideal, then the fundamental concepts, and finally examples of containers and algorithms. The key notions of sequence and iterator used to tie data together with algorithms (for general processing) are also presented. Stroustrup/Programming - Nov'13 Overview Common tasks and ideals Generic programming Containers, algorithms, and iterators The simplest algorithm: find() Parameterization of algorithms find_if() and function objects Sequence containers vector and list Associative containers map, set Standard algorithms copy, sort, Input iterators and output iterators List of useful facilities Headers, algorithms, containers, function objects Stroustrup/Programming - Nov'13 Common tasks Collect data into containers Organize data For printing For fast access Retrieve data items By index (., get the Nth element) By value (., get the first element with the value "Chocolate") By properties (., get the first elements where “age Stroustrup/Programming - Nov'13 Observation We can (already) write programs that are very similar independent of the data type used Using an int isn’t that different from using a double Using a vector isn’t that different from using a vector Stroustrup/Programming - Nov'13 Ideals We’d like to write common programming tasks so that we don’t have to re-do the work each time we find a new way of storing the data or a slightly different way of interpreting the data Finding a value in a vector isn’t all that different from finding a value in a list or an array Looking for a string ignoring case isn’t all that different .
đang nạp các trang xem trước