Analysis of map usage in STL [full version]
1 Map OverviewSTL (Standard Template Library) is the core of the C ++ standard library, which profoundly affects the overall structure of the standard library. STL is a general library that provides a series of software solutions and uses advanced and efficient algorithms to manage data. The advantage of STL is
STL is an important part of the C ++ standard library. It is not only a reusable component library, but also a software framework that contains algorithms and data structures, it is also a good example of C ++ generic programming. Many advanced C ++ technologies are used in STL. This article describes the application of the template-specific technology. Mainly refer to "C ++ Primer" and "
No secret before source code. -- Hou Jie
For a classic book, you can get it again every time you read it:
Chapter 1: STL Introduction
STL design thinking: the coupling of objects is extremely low, the reusability is extremely high, and the library conforms to the Development closed principle.
STL value: 1. It brings us a set of useful parts and an integrated org
STL provides a number of generic containers, such as vector,list and map. Programmers use these containers only to care about when to plug objects into the container, not to care about how to manage memory, how much memory to use, these STL containers greatly facilitate the writing of C + + programs. For example, you can create a vector with the following statement, which is actually an on-demand dynamic ar
the use of CL parameters to compile, is still a side dish, will only use the simple Generation command, and will not write a perfect makefile.When I use this set of environment to try to compile STLport project, there is a situation where cl.exe exits directly. So in the end I also used the VS comes with Environment settings batch command: Vcvarsall.bat, sample in vs2012: C:\Program Files (x86) \microsoft Visual Studio 11.0\vc\ Vcvarsall.bat. You can compile the STLport-5.2.1 project by running
Study finished STL series BIS, Oneself wrote a program practicing! The program uses the architecture of the second series of articles. Study of one of the STL and the second, for the basic principles of STL have a fundamental understanding. In fact, about these kinds of containers, have been contacted before, but in Java, when learning is also swallowed! Now feel
Effective STL Chinese version (Daquan)WinterIn the case of STL, programmers have three realms, starting with STL, then understanding STL, and finally supplementing STL. Effective STL is a very good book to help you better understa
STL contains methods used to iterate elements in containers-iteration methods, including for_each, transform, copy, find, remove
1. Usage:
// Template function, print element
2. Details
How to Implement for_each? Below is the source code of STL (excluding some diagnostic code)
// Template function for_each
We can see that every element in the iteration container is used as a parameter to call the third p
Template is a good thing. Classic STL. powerful boost.
Dynamic Link is also a good thing. It is called DLL in windows and so (Share Object) in Unix. It can save a lot of trouble for software re-release.
However, when a template encounters a dynamic link, it is often a nightmare.Now let's talk about some of the problems I have encountered. The problems are mainly focused on memory allocation.1>For STL, it is
Anti-DDoS program module indirectly transmits STL instance objects through struct
We often pass parameters to functions through struct. In principle, the struct should not contain non-pod members.
[Reference]========================================================== ==========================================Pod, short for plain old data, a common old data structure (POD) is a data structure. It is used only as the field value of passive favorites, and
STL provides many generic containers, such as vector, list, and map. When using these containers, programmers only need to worry about when to plug objects into the container, instead of how to manage the memory and how much memory is needed. These STL containers greatly facilitate the compilation of C ++ programs. For example, you can use the following statement to create a vector, which is actually an on-
Clause 38: design the imitation function class for value transfer
Neither C ++ nor C ++ allows you to pass functions as parameters to other functions. Instead, you must passPointerTo the function. For example, here is a declaration of the standard library function qsort:
void qsort(void *base, size_t nmemb, size_t size, int (*cmpfcn)(const void*, const void*));
Cla46 explains why the sort algorithm is generally a better choice than the qsort function, but it is not a problem here. The problem
Finally, I have the opportunity to have the motivation to view jjhou's STL source code parsing. It is expected that the entire book will be read in the fast-reading mode. The underlying mechanisms of map and set are RB-Tree (red-black Tree), and insertion and search are O (lgN) complexity. Map and set have been heard before, but they are never used, because they do not know what is behind them. I read this book to learn about it.
Finally, I have the
1. Why to build STL: The improvement of the reusability of the program (based on the standard)2, the value of STL:1) STL brings the most useful components2) "Taxonomy of software Components" based on generic thinking3, a sentence summed up the STLSTL implements an interface standard that is based on an abstract conceptual framework.Under this interface, any compo
Incomplete list of STL technical articles (STL learning User Guide)
Standard Template Library (STL) Introduction (I) Local stickers
This article uses the list container as an example to introduce the basic content of STL, from the container to the iterator, and then to the common functions. The examples are rich and
STL, Standard Template Library, is the implementation of C + + for generic programming ideas, which was first developed by HP Labs. This technology has existed for a long time before being introduced to C + +. Later STL became part of the Ansi/iso C + + standard. Each C + + vendor also has its own template library, which may be highly efficient, but portability is not necessarily good.In the C + + standard,
Description: I think to read the source code of allocator part of STL, and draw its thought, at least the following knowledge you want to understand: operator new and operator delete, handler function and a bit of template knowledge. Otherwise, you may not be able to see the following, add some knowledge to learn STL source is better.The following is a combination of the key source code Analysis C++
0 Preface: STL, why do you have to master
For programmers, data structures are a compulsory subject. From the search to the sort, from the list to the two fork tree, almost all algorithms and principles need to understand, can not understand also to memorize. Fortunately, these theories have been more mature, the algorithm is also basically fixed, do not need to spend your mind to consider the principle of its algorithm, and no longer to verify its a
Hou Jie said: Tracking first-class programs, absorbing nutrients from them, and imitating the programs he wrote are much more valuable than the third-stream programs that he thinks he is trying to write, at least I think so-99.999% of the world's programs are at the bottom of the three streams in front of STL!
Mr Hou Jie's comment on STL is too high. He used to be familiar with
Simplified STL (Chinese)
Author: winter
He said that for STL, programmers have three realms: using STL, understanding STL, and adding STL. Negative STL is a very good book that helps you better understand
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.