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
Document directory
Iterator type
Pointer iterator
Container iterator
Constant iterator
Iterator
The iterator provides an access method for objects in a container and defines the range of objects in the container. The iterator is like a pointer. In fact, the pointer of C ++ is also an iterator. However, the iterator is not just a pointer, so you cannot think that they must have an address value. For example, an array index can also be considered as an iterator.
The iterator has different cr
Allocator and stlallocator for stl Analysis
Allocator encapsulates the memory management system of the stl standard library. The string, container, algorithm, and some iostreams of the standard library are allocated and released through allocator. The component of the standard library has a allocator class specified by the parameter. For example, the prototype of vector is:
template
The second parameter _ A
Houtie teacher in the "STL Source Analysis" said: Understand traits programming technology, just like to get "sesame open" mantra, from this to a glimpse of the mysteries of STL source. The importance of such a word is self-evident.The iterator has been introduced before, knowing that different data structures have their own specific iterators, different iterators also have different characteristics, becaus
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
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
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
I 've been so busy recently, but I still want to write something of my own. I don't know what to write. Finally, I decided to try to implement several collections commonly used in STL by myself, to deepen my understanding of STL, and to see if I have the ability to implement it. The implementation goal is: 1 to be compatible with STL; 2 to maximize the implementa
Efficient Use of STLis only a choice of the problem, are STL, may be written out of the efficiency of several times;Familiar with the following terms, efficient use of STL;When the object is large, create a container of pointers instead of objects1) STL works on a copy-based approach, and any elements that need to be placed in the
From http://www.vckbase.com/
Author: yy2better
Introduction: This article describes how to export STL classes and methods that contain STL classes in DLL. Example source code
DLL cannot directly export the generic template (generalized template). Therefore, if you want to export the STL class, the template must be instantiated first (instantiated ). In addition,
The STL container class stores and Manages objects. Although there are no clear restrictions on the inclusion of pointers in STL container classes, STL does not care whether you store objects in containers or pointers. However, considering the original intention of STL, it is obviously out of date to use pointers in th
Auto_ptr source code, refer to the C ++ standard library
/* The following code example is taken from the book * "The C++ Standard Library - A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in all copies. * This software i
First of all: The following article is for the use of Windows, because the Std::map erase function of the Windows implementation version is to return a std::map iterator, but the STL standard inside the return value of the function is actually:There are 3 overloads of the Map.erase:void Erase (iterator position);Size_type Erase (const key_type x);void Erase (iterator first, iterator last);。So the last example in the code below can only be run under a
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.