Learn STL--Introduction to STL

Source: Internet
Author: User

STL Introduction

STL, the standard Template Library, is a collection of basic templates provided by the C + + language, originally developed by HP Labs and established as a standard library for C + + in 1998.

In the C + + standard, STL is organized into 13 header files:<algorithm>, <deque>, <functional>, <iterator>, <vector>, < List>, <map>, <memory>, <numeric>, <queue>, <set>, <stack> and <utility>. The STL consists of a space manager, an iterator, a functional, an adapter, a container, and an algorithm 6 part, of which the first 4 parts serve the latter two parts.


The Space Manager provides a user-defined memory request and release capability for the container class template. By default, the STL uses the memory management functions or operators of C/C + + to complete dynamic memory requests and releases. Instead of using these methods, users can redefine their own new policies to implement memory management.
Iterators are used to store an object's address (point to an object), either to provide data input to an algorithm in the STL or to traverse objects in a container class or stream. Pointers can be thought of as an iterator.
By introducing a functional, you can provide some strategies for the algorithm. In STL, if a class overloads the function call operator "()", the class is called a functional class, and its object is called a functional.
The adapter object binds itself to another object, which transforms the operation of the adapter object into an operation on the bound object. There are container adapters, iterator adapters, and functional adapters in the STL.
A container is a data structure that can contain several objects and provides a small number of operating interfaces. STL provides three standard containers: sequential containers, sorting containers, and hash containers, and three containers are stored in completely different ways, so even the same operating efficiency is different.
Sequential containers: Include vectors, lists, and double-ended queues.
Sorting containers: Includes collections, multiset, mappings, and Multimap.
Hash container: Includes hash set, hash multiset, hash map, and hash multimap.
In STL, all algorithms are provided in the form of function templates. The next step is to introduce the implementation of some algorithms.

Learn STL--Introduction to STL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.