STL General Summary of C + +

Source: Internet
Author: User

Re-review the STL

What is STL?

STL (template and Standard Template Library), which implements type-independent algorithms and data types, requires that the type in the implementation be parameterized, allowing the user to make different types according to its needs.

one or one-like introduction

STL, the standard Template Library, is a highly efficient C + + library with industrial strength. It is housed in the C + + standard library, which is the newest and most revolutionary part of the Ansi/iso C + + standard. The library contains many basic data structures and basic algorithms commonly used in computer science. For the vast number of C + + programmers to provide a scalable application framework, highly reflects the reusability of software.

From the logical level, the concept of generic programming is embodied in STL (generic programming), which introduces many new nouns, such as requirements (requirements), concepts (concept), model, Container (container), algorithm (ALGORITHMN), Iteration sub (iterator), etc. Like the polymorphism (polymorphism) in OOP (object-oriented programming), generics are also a reusable technology of software.

From the implementation level, the entire STL is implemented in a type-parameterized (type parameterized) way, based on a language feature that did not appear in the previous C + + standard-template. If you look at any one version of the STL source code, you will find that the template as the cornerstone of the entire STL is a true thing. In addition, many new features of C + + provide convenience for STL implementation.

Second, the six components of the STL

  • A container (Container) is a data structure, such as List,vector, and deques, provided as a template class method. To access the data in the container, you can use an iterator that is output by the container class;
  • Iterator (Iterator), which provides methods for accessing objects in the container. For example, you can use a pair of iterators to specify a range of objects in a list or vector. An iterator is like a pointer. In fact, C + + pointers are also an iterator. However, iterators can also be class objects that define operator* () and other operator-like methods that are similar to pointers;
  • Algorithm (algorithm), which is a template function used to manipulate the data in a container. For example, the STL uses sort () to sort the data in a vector, search for an object in a list with find (), and the function itself is independent of the structure and type of data they manipulate, so they can be used on any data structure from a simple array to a highly complex container;
  • The functor (function object, functor (functor), also known as the functional objects, is actually a struct that overloads the () operator, and there is no special place
  • Iterative Adapters (Adaptor)
  • Space Formulators (allocator) The main work consists of two parts 1. Object creation and destruction 2. Memory acquisition and release

STL General Summary of C + +

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.