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
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
algorithm parameter.
It is generally more efficient to pass the code generated by passing the STL function object-disguised as the function object-to the algorithm. The reason is inline. Another reason for replacing functions with function objects is that they can help you avoid subtle language traps.
Article 47: Avoid writing only code
Software that cannot be read or understood cannot be maintained, and
Reference an article translated on the MS Website:STL std: string class causes crash and memory damage on multi-processor computersHttp://support.microsoft.com/default.aspx? Scid = kb % 3Bzh-cn % 3B813810
Original English:Http://support.microsoft.com/default.aspx? Scid = kb; en-us; 813810
--------- Abstract --------------Symptom
Cause
Solution
Method 1: use Microsoft Visual C ++. NET (7.0 and later)
Method 2: Use Microsoft Visual C ++ 6.0 to remove STL
STL
1. Introduction to STL
STL (Standard Template Library) is a collection of software developed by the HP lab. It was developed by Alexander Stepanov, Meng Lee, and David R musser while working at the HP lab. Although it mainly appears in C ++, this technology has existed for a long time before it was introduced into
' attribute byte count ' –in the standard F Ormat, this should is zero because Mostsoftware does not understand anything else.Floating point numbers was represented as IEEE floating point numbers and was assumed to being little endian, Althoughthis is not stated in documentation.Uint8[80]–header//which is generally ignored–but which should never begin with ' solid ' because Ftware to assume that's an ASCII STL fileUint32–number of triangles//indicati
After the ANSI/iso c ++ STL standard version is officially passed, each C ++ compiler vendor can implement the C ++ STL generic library according to the prototype described in the standard, as a result, there are a variety of generic Libraries that comply with the standard interface, but the specific implementation code is different, mainly including:
HP STL
Hp
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
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.