http://blog.csdn.net/leolin_/article/details/7315975
The erase function is prototyped as follows:(1) string erase (size_t pos = 0, size_t n = NPOs);(2) Iterator erase (iterator position);(3) Iterator erase (iterator first, iterator last);That means there are three ways to use:(1)
Sequent container: (vector)Erase not only invalidates all iterators pointing to the deleted element, but also invalidates all iterators after the deleted element. Therefore, the erase (ITER ++) method cannot be used, however, the returned value of erase is the next effective iterator.
The correct method is ::For (iter = C. Begin (); iter! = C. End ();)
Iter = C.
Correct use of the erase method of STL Map
In the STL map table, an erase method is used to delete the command node from a map.
Eg:
Map
Typedef Map
ITER iter = maptest. Find (key );
Maptest. Erase (ITER );
As shown in the preceding figure, only deleting a single node does not cause task problems,
However, when used in a loop, it is often misused b
Flash.There is a big difference between the life of NAND and NOR, the speed of block erase, the chance of error in data storage, and so on.The write operation of any flash device can only be done within an empty or erased unit, so in most cases the erase must be performed before the write operation. The erasure of NAND devices is straightforward, and nor does it require that all bits in the target block be
The first time to write a blog, what to say is not difficult, on the question of generics, is a burst of learning in Jackson encountered.The following will be what I think of, meet, share out.Generics are an attribute after JDK1.5, an application of a parameter type that can be declared in a class, interface, or method, just like a local variable defined in our method, and in work we often use it in a collection object such as List,map,set, or in a class we declare ourselves.When it comes to gen
Win10 How to erase the hard drive deleted files completely?
Action method:
This feature is present in Windows XP, Win7, Win8.1, and Win10, and the system has a command-line tool named Cipher, which uses EFS to encrypt file systems to encrypt files. However, this tool also has an additional feature that can be used to erase the rest of the space on the hard disk, thereby safely removing the deleted
There are more and more people using STL. STL is indeed a set of beautiful algorithms and data structure libraries, but people who use STL at first often encounter many problems.Deleting an element from a container is a very common operation, but it is also a common mistake for beginners. The last time baosong found an error occurred when deleting the elements in map and list. vector is a very common container in STL. Compared with containers such as map and list, it is more troublesome to delet
Sequential containers::(vectors and lists and deque)The erase iterator not only invalidates all iterators that point to the deleted element, but also invalidates all iterators after the deleted element, so erase (iter++) cannot be used, but the return value of erase is the next valid iterator, so the correct method is:: For (iter = C.begin (); ITER! = C.end ();)i
The 3rd chapter of library function, which is about the problem of library function, is introduced in this chapter. Using library functions can reduce the difficulty of software development and improve the efficiency of code writing. This section introduces the misuse of the Multiset container erase function.Ad:51cto Net + 12th salon: The beauty of big data-how to drive user experience with dataMisuse of erase
Vector::erase (): Deletes an element in a specified position or a range of elements from a specified containerThere are two overloaded forms of the Vector::erase () methodAs follows:Iterator Erase (iterator _where);Iterator Erase (iterator _first, iterator _last);If you are deleting an element at a specified locati
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
When I wrote a small example today, I encountered the following problem: I want to traverse a vector, but when some conditions in the traversal process are met, I plan to delete the elements of the composite condition. Use erase to permanently delete the file when deleting the file, and then continue to traverse the file. (in this case, I have seen it on Objective C ++, but I cannot find it. I still remember there is a solution, so you can find a solu
Erase () trap of STL-iterator failure summary, stlerase
The following materials are collected from Internet books.Containers in STL are divided into two types by storage method: containers stored in arrays (such as vector and deque), and containers stored in discontinuous nodes (such: list, set, map ). When using the erase method to delete elements, pay attention to some issues.1. list, set, map container
Generic Erase and transformTeacher: Wang Shaohua QQ Group: 483773664 Learning Objectives:
Mastering the meaning of generic erase
Understanding rules for generic conversions
First, generic erase(a) What generic eraseGenerics in Java are basically implemented at the compiler level. In the generated Java bytecode, the type information in the generi
This example describes the jquery horizontal erase focus tut effect. Share to everyone for your reference. Specifically as follows:Thunderbolt jquery Horizontal Erase focus diagram is a jquery based on the implementation of the 7-screen horizontal erase focus diagram Code, there are thumbnails and headings, you can customize the title.Run Effect chart:-----------
Erase and vectorerase used in vector
As a result of a previous misunderstanding of vector found in the use of the latest project, we found that we do not know much about vect, so we want to write a bit about it.Attention in vector usage. In this article, we will first talk about the erase function of vector. If there is any error, please point outFirst, I wrote a function to print the vector memory and prin
A Take a look at several methods and properties:1. Qwidget * Qscrollview::viewport () const2. void Qwidget::p aintevent (qpaintevent *) [Virtual protection]3. void Qwidget::repaint (int x, int y, int w, int h, bool erase = TRUE) [slot]4. void Qwidget::update () [Groove]5. void qwidget::erase (int x, int y, int w, int h)6. BOOL UpdatesenabledTwo Now in detail:1. Qwidget * Qscrollview::viewport () constReturn
Sometimes there is a less common requirement: deleting all projects that meet certain conditions from a map has nothing to do with the map key.
For example, a map storing the student roster has the key as the student ID (INT) and the value as the name (string). It is easy to delete the map by student ID, however, if you need to delete all the students with the "Zhang" name in the map, you can only traverse it and compare them one by one.
Using namespace STD;
Below is the obviousError Method
:
/
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service