Preface
Function objects are also important in STL, and sometimes the behavior of STL algorithms can be limited. For example, in the STL algorithm analysis described earlier, each algorithm basically provides two operation versions, one of which allows you to specify the function object. This allows you to operate the algorithm based on your needs. Function objec
specialization. Of course, for compilers that do not support this function, manually compile the template specialization to define a more optimistic value. Otherwise, the default value__false_typeWill take effect.Sgi stl Extraction
Defined by SGI STL__type_traitsIn addition to the featureshas_trivial_default_constructorAndhas_trivial_destructorAnd other features, as described below:
Application Scenario-copy
Template Functionscopy()YesSTLA generic a
, based on the specific situation, the template is used to set a more optimistic value for the specific type. for example, the built-in int type definition template is special:
template
According to __type_traitTemplate specialization. Of course, for compilers that do not support this function, manually compile the template specialization to define a more optimistic value. Otherwise, the default value__false_typeWill take effect.Sgi stl Extraction
De
the selection of Certain types through the template mechanism until you really want to use the template or make the template special, STL uses this to provide many useful algorithms. It completes these algorithms in an effective framework-you can divide all types into a few categories, then, you can use one type in the template parameter to replace other types in the same type.
element to the list header.Rbegin () returns the reverse iterator pointing to the first element.Remove () delete an element from the listRemove_if () deletes an element based on the specified conditions.Rend () points to the reverse iterator at the end of the listResize () changes the list size.Reverse () Reverse the list elementSize () returns the number of elements in the list.Sort () sorts the listSplice (iterator position, list X) // list. splice (Position, list2) // prior to position in l
I. Category:
StandardSTLSequential container: Vector, String, deque, and list.
StandardSTLAssociated container: Set, Multiset, map, and multimap.
Non-standard sequence containerSlist and rope. Slist is a one-way linked list, and rope is essentially a heavy string
Non-standard associated containerHash_set, hash_multiset, hash_map, and hash_multimap.
Several TypesStandard non-STLContainerIncluding array, bitset, valarray, stack, queue, and priority_queue
It is worth noting that arrays can wo
Preface:
Learning C ++ is now the ninth day, so I just have a simple understanding of C ++ theoretically. I have no practical experience in practical application. so next we will analyze the sgi stl source code.Article, More
This is just a direct analysis of the source code, and there is no experience on the actual application scenario. So we only talk about the source code, and nothing else.
For Hou Jie's article
I have referenced some good
Structure and uses a map (not a map in STL) to manage these segments. Map is a continuous space, and each element is a pointer. Point to another larger continuous linear space and become a buffer zone. The buffer zone is the subject of the deque bucket. Buffer expansion is quite complicated !!!
[Note] deque is a better choice when using the insert/delete operation. It is more appropriate to select vector in other cases.
2) Use
Header file to be load
operation is unsuccessful and ineffective, then you should use list or associative container.5. If you often need to search for elements based on a guideline, you should use the set or multiset to sort the elements with that sort criteria. Remember, in theory, the logarithm complexity is 10 times times better than the linear complexity in the order of 1000 elements. In terms of search speed, hash table is usually 5-10 times faster than a binary tree. But the elements of the hash table are not s
See more details: https://zcheng.ren/2016/08/23/STLVector/
In C + + because the array can not dynamically expand, so in the STL set vector to achieve the role of dynamic array, by allocating contiguous memory space to store elements, if the insertion of elements when the memory space is not large enough, you can reassign the memory to implement a dynamic array.The vector's structure consists of 3 parts: The starting iterator that marks the starting p
and their comparisons, I'll tell you, qsort and sort are the same, because they're all sort of fast. In terms of efficiency, the following sort algorithms are sorted, with efficiencies ranging from high to low (time-consuming from small to large):
Partion
stable_partition
nth_element
partial_sort
sort
stable_sort
Remember, the previous translation of the effective STL article, which summed up how to selec
NLP self-dream's STL algorithm learning in TianyaSTLAlgorithmSummary:
Prerequisites:
Download STL Source: http://www.sgi.com/tech/stl/download.htmlOpen Web: http://www.sgi.com/tech/stl/stl_index.html
One function object: Function objects are used in many algorithms.
Binary Function object. V1 and V2 are input a
I. Overview
Priority_queue is the queue with the concept of ownership. It allows new elements to be added and old elements to be removed. Call make_heap (), pop_heap (), push_heap () in STL ()AlgorithmImplementation is another form of heap. However, it is a queue, so only elements can be added at the bottom and removed from the top.
Sort: sort by weight, rather than by push. The higher the weight, the lower the weight.
It is allowed to be insert
Algorithm: Used to process elements within a cluster. They can search, sort, modify, and use those elements for different purposes. An action or function that is applied to a container to handle its memory in various ways, such as sort (sort), copy (copy) ...
The algorithm is embodied by the template function, which is not a member function of the container class, is a stand-alone function, they can be used in STL container, and can be used in ordina
※Management books are basically about how to manage others, but they talk about how to make managers manage themselves and make managers more effective.
※Management does not lie in knowledge, but in rows. (Integration of knowledge and industry)
※Not only do the right thing, but also do the right thing ".
※What is really important for external situations is not a trend, but a trend change.
※Effectiveness is a habit of the day after tomorrow and a combi
Original address: http://www.cnblogs.com/duzouzhe/archive/2010/01/12/1645191.htmlThe STL container can be divided into the following major categories:One: Sequence container: Vector, List, deque, String.II: Associative containers: Set, Multiset, map, Mulmap, Hash_set, Hash_map, Hash_multiset, Hash_multimapIII: Miscellaneous: Stack, queue, Valarray, BitsetImplementation of various STL containers:(1) VectorIn
More effective C ++: 35 effective methods to improve programming and designChinese version) China-Pub computer New Book recommendation
Basic InformationOriginal Title: more effective C ++: 35 new ways to improve your programs and designsOriginal Press: Addison-Wesley professionalAuthor: (US) Scott MeyersTranslator: Hou JieSeries name: Classic BooksPress: Electro
Certain types through the template mechanism until you really want to use the template or make the template special, STL uses this to provide many useful algorithms. It completes these algorithms in an effective framework-you can divide all types into a few categories, then, you can use one type in the template parameter to replace other types in the same type.
STL
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.