Bài giảng Lập trình hướng đối tượng: Chương 6 - ThS. Bùi Trọng Hiếu
Số trang: 117
Loại file: pdf
Dung lượng: 1.13 MB
Lượt xem: 11
Lượt tải: 0
Xem trước 10 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Chương 6 trình bày về Standard Template Library (STL) với một số nội dung như: Origins of STL, generic programming, STL components, STL installation, STL header files, STL incompatibilities,... Mời các bạn cùng tham khảo.
Nội dung trích xuất từ tài liệu:
Bài giảng Lập trình hướng đối tượng: Chương 6 - ThS. Bùi Trọng Hiếu Chương 6 Standard Template Library 1Lập trình hướng đối tượng - STL The Standard Template Library • Origins of STL • Generic programming • STL components • STL installation • STL header files • STL incompatibilities 2Lập trình hướng đối tượng - STL The Standard Template Library • The Standard Template Library (STL) is a general-purpose library of container classes (such as vectors, lists, sets and maps) and generic algorithms (such as searching, sorting and merging). • The chief difference between STL and other C++ libraries is that STL containers and algorithms can be plugged together in a myriad of different useful ways. 3Lập trình hướng đối tượng - STL Problems with libraries • Writing your own library of container classes can be very frustrating because, even if you are familiar with the best techniques, there is rarely time to implement them. • Buying a commercial library also has its drawbacks: – Incompatibility – Inefficiency – Unwieldy interfaces 4Lập trình hướng đối tượng - STL Origins of STL• In view of these problems, the ANSI committee for C++ standardisation sought a standard set of container classes.• Alexander Stepanov and Meng Lee of Hewlett Packard Laboratories proposed STL, and in 1994 it was accepted as part of the C++ Standard Library. 5Lập trình hướng đối tượng - STL Why STL? • STL was chosen as the ANSI standard for several reasons: – Efficiency – Iterators – Generic algorithms – Function objects – Allocators 6Lập trình hướng đối tượng - STL Generic programming • Research into generic programming has aimed to produce libraries of generic, or reusable, software components. 7Lập trình hướng đối tượng - STL Generic programming •Each iterator defines the operations that are needed to access the contents of a particular type of container. •Class templates are used to define containers and iterators, and function templates are used to define generic algorithms. 8Lập trình hướng đối tượng - STL Generic programming •Not every generic algorithm and iterator can be plugged together. STL prohibits some combinations because certain algorithms are only efficient when they are used with certain types of containers. 9Lập trình hướng đối tượng - STL STL components • Containers • Generic algorithms • Iterators • Adaptors • Function objects • Allocators 10Lập trình hướng đối tượng - STL Containers • A container is a data structure that stores a collection of objects. • STL defines two categories of containers: sequential containers and associative containers. 11Lập trình hướng đối tượng - STL Sequential containers • Sequential containers store items in a linear structure. The three sequential container types are: vector deque list 12Lập trình hướng đối tượng - STL Associative containers• Associative containers store items in a structure suited for fast associative lookup. The four associative container types are: set multiset map multimap 13Lập trình hướng đối tượng - STL Generic algorithms (I) • In traditional container class libraries, all of the algorithms associated with a particular class are implemented as member functions of that class. • In contrast, most STL algorithms are written as external functions that interact with container classes via iterators. 14Lập trình hướng đối tượng - STL Generic algorithms (II) • Each algorithm can opera ...
Nội dung trích xuất từ tài liệu:
Bài giảng Lập trình hướng đối tượng: Chương 6 - ThS. Bùi Trọng Hiếu Chương 6 Standard Template Library 1Lập trình hướng đối tượng - STL The Standard Template Library • Origins of STL • Generic programming • STL components • STL installation • STL header files • STL incompatibilities 2Lập trình hướng đối tượng - STL The Standard Template Library • The Standard Template Library (STL) is a general-purpose library of container classes (such as vectors, lists, sets and maps) and generic algorithms (such as searching, sorting and merging). • The chief difference between STL and other C++ libraries is that STL containers and algorithms can be plugged together in a myriad of different useful ways. 3Lập trình hướng đối tượng - STL Problems with libraries • Writing your own library of container classes can be very frustrating because, even if you are familiar with the best techniques, there is rarely time to implement them. • Buying a commercial library also has its drawbacks: – Incompatibility – Inefficiency – Unwieldy interfaces 4Lập trình hướng đối tượng - STL Origins of STL• In view of these problems, the ANSI committee for C++ standardisation sought a standard set of container classes.• Alexander Stepanov and Meng Lee of Hewlett Packard Laboratories proposed STL, and in 1994 it was accepted as part of the C++ Standard Library. 5Lập trình hướng đối tượng - STL Why STL? • STL was chosen as the ANSI standard for several reasons: – Efficiency – Iterators – Generic algorithms – Function objects – Allocators 6Lập trình hướng đối tượng - STL Generic programming • Research into generic programming has aimed to produce libraries of generic, or reusable, software components. 7Lập trình hướng đối tượng - STL Generic programming •Each iterator defines the operations that are needed to access the contents of a particular type of container. •Class templates are used to define containers and iterators, and function templates are used to define generic algorithms. 8Lập trình hướng đối tượng - STL Generic programming •Not every generic algorithm and iterator can be plugged together. STL prohibits some combinations because certain algorithms are only efficient when they are used with certain types of containers. 9Lập trình hướng đối tượng - STL STL components • Containers • Generic algorithms • Iterators • Adaptors • Function objects • Allocators 10Lập trình hướng đối tượng - STL Containers • A container is a data structure that stores a collection of objects. • STL defines two categories of containers: sequential containers and associative containers. 11Lập trình hướng đối tượng - STL Sequential containers • Sequential containers store items in a linear structure. The three sequential container types are: vector deque list 12Lập trình hướng đối tượng - STL Associative containers• Associative containers store items in a structure suited for fast associative lookup. The four associative container types are: set multiset map multimap 13Lập trình hướng đối tượng - STL Generic algorithms (I) • In traditional container class libraries, all of the algorithms associated with a particular class are implemented as member functions of that class. • In contrast, most STL algorithms are written as external functions that interact with container classes via iterators. 14Lập trình hướng đối tượng - STL Generic algorithms (II) • Each algorithm can opera ...
Tìm kiếm theo từ khóa liên quan:
Lập trình hướng đối tượng Bài giảng Lập trình hướng đối tượng Standard Template Library Origins of STL Generic programming STL componentsGợi ý tài liệu liên quan:
-
Giáo trình Lập trình hướng đối tượng: Phần 2
154 trang 276 0 0 -
101 trang 200 1 0
-
14 trang 134 0 0
-
Giáo trình lập trình hướng đối tượng - Lê Thị Mỹ Hạnh ĐH Đà Nẵng
165 trang 112 0 0 -
Giáo trình Lập trình Windows 1 - Trường CĐN Đà Lạt
117 trang 96 0 0 -
Giáo trình Phân tích, thiết kế hướng đối tượng với UML: Phần 1 - Trường ĐH Công nghiệp Quảng Ninh
111 trang 95 0 0 -
265 trang 80 0 0
-
Giáo trình Lập trình hướng đối tượng với Java: Phần 2 - Trần Thị Minh Châu, Nguyễn Việt Hà
141 trang 75 0 0 -
33 trang 70 0 0
-
Ngôn ngữ lập trình C# 2005 - Tập 3: Lập trình hướng đối tượng (Phần 1)
196 trang 51 0 0