When using a std::list
The list in the STL is a two-way linked list, which can be inserted efficiently to delete elements.
The list does not support random access. So there is no at (POS) and operator[].
The list object List1, List2 has element List1 (1,2,3), List2 (4,5,6) respectively. list
Construction, deconstruction
List
### Other ###
C.size ()///Returns the number of elements in the container
c.swap (C2)///convert C2 an
List is implemented by bidirectional linked list, the following mainly introduces some operation of STL list.
Description: For examples and function declarations not given, see http://www.cplusplus.com/reference/
Implementation: Bits/stl_list.h, BITS_STL/LIST.TCC (libstdc++ or include/c++) 1. Constructor, assign (), size (), max_size (), resize () 1. Constructor function
Explicit list (const allocator_type alloc = Allocator_type ());
Explicit list
If we implement a linked list by ourselves, we will write a lot of code, including the implementation of creation, deletion, insert, and so on. But if we use STL, then the template Library provides us with a two-way list of linked lists, so that we can easily implement the linked list operation. To use list, first introduce the header file #include
(1) Create List
ListThere are several ways to create a list.
(2) push_back (), tail insertion
In the data structure there is also a very common queue called the two-terminal queue, we in the last blog, "C + + STL learning--queue" in the queue is the most standard queue, only at the end of the insertion of data, the head to delete data. And today we talked about the deque can be inserted at both ends of the insertion and deletion, can be said to use more flexible. Sample code uploaded to Https://github.com/chenyufeng1991/STL_deque.
(1) Create a
");//
(SUBSTR): Fetch substring
substr
String stringsubstr = "Chenyufeng";
3 characters starting with index 4
cout
Find: Finding a character
Find
string stringfind = "Chenyufeng";
Stringfind.find (' n ');
cout
The default find function is the subscript index that returns the first occurrence of a character. Find_first_of and find_last_of are respectively the first and last occurrences of a character's index.
The string processing functions in these 15 C +
Currently, vectors and maps are the most commonly used two containers in the STL, and when using vectors or maps, they are found in the container as needed and then removed, summarizing the correct results in the actual test.
Find:
Map Lookup uses the Find function.
map
iter = Mapintstring.find (1);
if (iter! = Mapintstring.end ())
{
Todo:
}
There is no find function in the vector and can only be searched by traversal.
Vector
for (UINT i
Review the "STL Source Analysis", first of several simple algorithms to achieve their own. Parameter does not use an iterator and uses an integer array directly.#include
value_type* data () noexcept;const value_type* data () const noexcept;returns a pointer to the location of the vector element stored directly in memory. Because the elements inside the vector are stored sequentially, the pointer can access all the elements in the array by an offset.ParametersNoneReturn ValueReturns a pointer to the memory where the first element of the array resides.——————————————————————————————————————————————————————————————————Summary of the bad place please a lot of
Sequencing is always the most commonly used algorithm in data structure, and the algorithm of STL is very rich, and how to use it effectively is worth discussing. I did not find the translation of clause 31 on the Internet, so I translated it myself. --Winter
How do I sort? Let me count there are several ways.
Once the programmer needs to sort the container elements, the sort algorithm will immediately appear in his mind (some programmers may think
See an article on your Web site: "Insert different types of objects in an STL list (Lists)." I feel that the answer has not pointed out the nature of the problem, so I put forward my point of view, I beg to correct. I think that the cause of the error is the pointer transformation process, the program did not point out the original prototype of the pointer, or, because did not find the correct subclass function address to invoke the error, my original
ZC: Here in the video there is a debugging tips, vs08/vs2010 start, the console program will automatically exit (unlike VC6), then you can set a breakpoint on the last sentence of the function exit, and then view the information printed by the console.ZC: This tells me that the good thing about using string is that the index is out of bounds when the string is manipulated (such as copy/delete operations)"01:05", the main points of this lecture are as follows:One, what things
Previously did not pay attention to the sorting algorithm, because there are very few application scenarios, the recent interview process found that the sorting algorithm is often asked, sometimes in some written or interview topics need to use the sorting algorithm to solve the problem, if each of their own handwritten sort, then it is quite time-consuming, And I don't necessarily write out the wrong sort algorithm in a short time, this time STL prov
STL source code analysis-Implementation of extraction programming (traits) technology, stltraits
1. Why?
By default, a template provides a single definition that can be used for any template parameters that you can think! However, for the person who writes the template, this method is not flexible, especially when the template parameter is a pointer, if you want to instantiate a parameter different from the type, it becomes impossible! Sometimes, it i
1. Why?
By default, a template provides a single definition that can be used for any template parameters that you can think! However, for the person who writes the template, this method is not flexible, especially when the template parameter is a pointer, if you want to instantiate a parameter different from the type, it becomes impossible! Sometimes, it is impossible to disable the same instantiation! So it appears, partial specialization!
At the same time, when using the void * pointer, you ca
Note: memory management is always the red-light area of the C/C ++ program. There are two focuses on memory management. One is the correct use of memory. For example, new and delete in C ++ should appear in pairs and use raiI to manage memory resources, auto_ptr and other aspects, many C/C ++ books use the introduction of skills. The other is the implementation of memory management, such as the slab distributor of the Linux kernel, Allocator implementation in
Author: the robe of anger
1. Introduction to STLSTL (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 C ++.In a broad sense, STL code is divided into three types: algorithm (algorithm), container (container), and ite
By posting articles on the STL Chinese site, I feel that I cannot find the address when I want to refer to it and simply post it to my blog.STL sorting (SORT)
Author winter
STL sorting (SORT)
Why do you have to master STL?
1. Sort Algorithm provided by STL
1.1 Introduction to all sort Algorithms
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 C ++.
In a broad sense,
Note: memory management is always the red-light area of the C/C ++ program. There are two focuses on memory management. One is the correct use of memory. For example, new and delete in C ++ should appear in pairs and use raiI to manage memory resources, auto_ptr and other aspects, many C/C ++ books use the introduction of skills. The other is the implementation of memory management, such as the slab distributor of the Linux kernel, Allocator implementation in
I recently used 3D files in STL format to learn how to add them to my favorites.
From: http://www.cnblogs.com/ourshell/archive/2010/05/03/1726821.html
STL can only be used to indicate closed faces or bodies. STL files can be in either the plaintext format or binary format. Its file format is very simple
Plaintext:Solid nameFacet normal Ni NJ NKOuter LoopVertex v1
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.