. Also, if you consider a platform transplant, it is better to use less.4.6 Do you have any suggestions for learning to use Hash_map?Hash Chinese is hashed, also become hash, hear others say hash container don't blame yourself ignorant. Learn about the hash series, you can also look at this article: effective STL 25: familiar with non-standard hash containers, it is also recommended to view the source code.
The common search algorithms are as follows:Find ()Find_if ()//Search_n ()Search ()Find_end ()Find_first_of ()Adjacent_find ()//These two methods are common, try out all the containers, but the lookup efficiency is slow, is the linear lookupFind () This complexity is linear complexityFIND_IF () This complexity is linear complexityAttention:1, if it is an ordered interval, you can use the ordered interval lookup algorithm (Binary_search includes () Lower_bound () Upper_bound ()).2, the associativ
Search_n () is used to find contiguous n-matched values or add predicatesSearch_n (b, E, C, v)Search_n (b, E, C, V, p)Note: The second form of the method should be search_n_if (b, E, C, p)#include STL STL Algorithm for C + +-Find algorithm (2)
The implementation principles of stl are simple and easy to understand, and stl principles are explained.
SummaryPlease use vector for frequent Random Access2. listA list is a two-way linked list, where elements are stored in the heap. Each element is stored in a piece of memory. Its memory space can be discontinuous and data access can be performed through pointers, this feature makes random access very in
STL Series 5: Queue container and stl series queue containerQueue Introduction
Queue is a queue container and a "first-in-first-out" container.
Queue is a simple deque container and becomes another container.
# Include
1. Default Construction of the queue object
The queue is implemented using the template class. The default construction form of the queue object is queue 2. The push () and pop () Metho
Summary of the basic usage of STL container vector and stl container vector
According to ACM program design, we use examples to demonstrate vector usage.
Methods: push_back (), insert (), erase (), clear (), size (), empty ();
Algorithm: reverse (), sort (), accumulate ().
1 # include
Scattered records of STL Learning (constantly updating), and stl learning is constantly updatedI write what I use, so I don't pay too much attention to typographical layout. I will sort it out after I write too much:
1: vector
2: The iterator cannot be set for the priority queue because there is no
3:
# Include
String str2 (str,); // truncate the str string Array 0 ~ Element 7, which comes with the
STL _ FUNCTION template, stl function Template
# Include # Include Using namespace std;
# Define MAX (T )\T max _ # T (T x, T y ){\Return x> y? X: y ;\}// Generate the following three types of functions during preprocessingMAX (int) // int max_int (int x, int y) {return x> y? X: y ;}MAX (double)MAX (string)
# Define mymax (T) max _ # T // The function name is replaced by a macro function
Int main (){Cout Co
STL container, stlArticle from http://blog.csdn.net/zhouyunxuanSeven sequence container types1. vector is a type of representation of arrays. It provides an automatic memory management function to dynamically change the length of a vector object and scale down as elements are added or deleted,It provides Random Access to elements. The time for adding and deleting elements at the end is fixed, but the complexity of inserting and deleting elements in th
In the previous article, the story about stl_vector is just the beginning. In this article, we will analyze the details in vector.
Again, I have not read any books on stl source code analysis. I emphasize that this is to prevent others from misunderstanding that I copied it from other places.
The subsequent articles will detail the function implementation in vector.I try my best to make it small, and I can try my best to use my own language and my ow
container and its size can be changed. It can improve the Data Reading Capability Based on keywords.(2) provides a two-way positioner to read and write data.(3)Sorted by keywords and a comparison Function.(4)All keywords are unique..(5) a template that provides a general and independent data type.
4) for more information about map, see resources.
Download STL map resources
5) combined with the map method, a comprehensive test is provided.Code:
Details: https://zcheng.ren/2016/08/24/STLList/
C + + implemented vector since it cannot be implemented to quickly delete and insert elements, the STL designer then proposes to use list to solve the problem: through the memory of discontinuous space allocation node, through the link to operate, can quickly achieve this advantage.The nodes of the list include: pointer prev to the previous node, pointing to the pointer to the back node next;Iterator is
will read the references below.Type extraction
The extraction (traits) programming technology makes upC++HoweverSTLIt only regulates the characteristics of the iterator and developsiterator_traits. Since this technology is so useful, it should be applied to more extensive application scenarios. sgi stl (STL version developed by the Silicon Graphics System) has made an attempt to apply it outside the world
As an indispensable part of the C + + standard, the STL should permeate the corner of C + + program. The STL is not the pet in the lab, nor the device on the programmer's desk, her excitement is not a flash in the pan. This tutorial is designed to disseminate and popularize the basic knowledge of STL, if can take this opportunity for the extension of
Managers must finish what they should do on time. In other words, managers must do things effectively.
Decisions made based on knowledge authority are of the same nature as decisions made by senior management.
Management's jurisdiction: planning, organization, integration, incentive and assessment.
Real problems that managers must face:
Managers often only belong to others rather than themselves.
Managers are often forced to "operate daily" unless they dare to act to change everything a
remove algorithm. The remove algorithm in the STL moves forward the element that should not be deleted, and then returns an iterator that points to the element that should be deleted, that's all. So if you want to really delete this element, you must also call erase after you call remove, which is the idiom for the "erase_remove" of the STL container element deletion.
Vector
Erase-remove's idiom applies t
, so that the ordered iterator remains valid (the sort iterator in the vector is invalidated). 3 Selecting the appropriate sorting function
Why choose the right sort function. Maybe you don't care about efficiency (the efficiency here is the program run time), or you have a small amount of data, so you think it doesn't matter which function to use.In fact, even if you do not care about efficiency, if you choose the appropriate sorting function, you will make your code easier to understand, you w
C ++ StandardProgramThe Library provides different containers with their own expertise. Now the question is: how do I select the best container category? The following table provides an overview.
However, some of the descriptions may not be practical. For example, if you need to handle a small number of elements, the complexity can be reduced because of the linearAlgorithmGenerally, the processing of elements is faster. In this case, "Explicit complexity and quick Element Processing" is mor
for network promotion Chen Manager Health nail: "With SKYCC portfolio marketing software, cost-effective higher!" Chen manager said: "The combination of marketing software benefits are many, convenient, easy to operate, not like the general marketing software like the operation of trouble, cumbersome, and the effect is not very obvious." More important is the combination of marketing software cost-effective
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.