effective stl

Read about effective stl, The latest news, videos, and discussion topics about effective stl from alibabacloud.com

Preface to "effective STL Chinese Version"

"Effective STL Chinese Version" PrefaceThe first time I wrote about STL (standard templatelibrary, Standards Template Library) was introduced in 1995, when I made a cursory introduction to STL in the last article in more effective C + +. Shortly thereafter, I received some e

Effective STL Chinese version (Daquan)

Effective STL Chinese version (Daquan)WinterIn the case of STL, programmers have three realms, starting with STL, then understanding STL, and finally supplementing STL. Effective

Effective STL 1th: Carefully select the container type

(Exception-safe) code. (a container that uses contiguous memory can also get transactional semantics, but it pays a performance cost and the code is less straightforward.)do you need to make the least number of iterations, pointers, and references invalid? If this is the case, use a node-based container because the INSERT and delete operations on such containers never make iterators, pointers, and references invalid (unless they point to an element that you are deleting). Insert and delete oper

Effective STL 7th: If the container contains a pointer created by the new operation, remember to delete the pointer before the container object is refactored

library. void DoSomething () { typedef boost::shared_ptrNever mistakenly think: You can make the pointer be automatically deleted by creating a auto_ptr container. The idea is dangerous, see effective STL 8th for specific explanations.What you have to remember is that the STL container is smart, but not intelligent to the extent that you

Effective STL (Container part Summary)

Still like effective part of the book, read several times, here the STL and container related to some basic points of attention to summarize, and then to summarize the iterator, etc.1 for a sequence container to be deleted, the iterator cannot be done in advance with the + + operation as the associated container, because deleting an iterator invalidates himself and the subsequent iterator is invalid, so the

Effective STL Recommendations

(iterator begin,iterator end);Interval Assignment:Void container::assign (Inputiteratorbegin,inputiterator end);The behavior of removing a derived object by a base-class pointer without a virtual destructor is undefined, and the process does not require a class that requires destructors to be risky.Do not create auto_ptr containers. Because when you copy a auto_ptr, the ownership of the object that auto_ptr points to is transferred to the auto_ptr of the copy, and the copied auto_ptr is set to

Effective STL--container

08. Never create a container object that contains Auto_ptr09. Carefully select the method to delete the element Delete specified value Vector,string,deque:c.erase (Remove (C.begin (), C.end (), value)); List:c.remove (value); Set,multiset,map,multimap:c.erase (value); Delete based on equivalence ( Remove the value of the discriminant to true Vector,string, Deque:c.erase (Remove_if (C.begin (), C.end (), judge)); for (Seqcontainer

Effective STL--vector and string

()) { dosomething (v[0], v.size ()) } String:s.c_str () s[0] is not necessarily reliable because the data in a string is not necessarily stored in contiguous space, and the internal representation of a string does not necessarily end with a null character. S.c_str () will put the first null character inside the string as the null character at the end. The pointer generated by S.C_STR () does not necessarily point to the internal representation of

"Effective STL" clause 24: When it comes to efficiency, you should choose between map::operator[] and Map::insert carefully.

If you want to update the existing map element, operator[] is better, but if you want to add a new element, insert has an advantage.More efficient "Add or update" functions (functions in the book I plucked out ~)TemplateTypeName Keyargtype,TypeName Valueargtype>TypeName Maptype::iteratorEfficientaddorupdate (maptype m,Const keyargtype K,Const valueargtype v){TypeName Maptype::iterator lb = M.lower_bound (k);if (lb! = M.end () ! ( M.key_comp () (k, Lb->first)) {//its key is equivalent to K ...Lb-

Effective STL to understand your sort operation

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

Effective STL clause 3

Ensure that objects in containers are copied correctly and efficientlyWhen using STL templates, we have to think about the issue of copying. If our custom type is stored in the STL. Some of the following issues may occur:First of allTo prevent the copying process from becoming a bottleneck for the program, we chose to store the custom pointers. However, there is a problem with wild pointers, so we need to u

Effective stl--switching techniques to modify excess capacity

Correction of excess capacity through "switching techniques"Suppose a vector is enlarged in the process of use, but in the subsequent process the elements in the vector are deleted, although the elements in the vector are deleted but the capacity of the vector is not smaller, that is, the original application of the memory space is not released, adding at a certain time the vector capacity of 10000, The number of elements in the last vector may be 10, then the excess space is wasted, and this ti

C + + Exercise records 2---effective vector<bool> in STL

//vs2013 32-bit Win8cout sizeof(BOOL) //1dequeBOOL> D (1);cout sizeof(d[0]) //1vectorBOOL> V (1);cout sizeof(v[0]) // -cout sizeof(d) // -cout sizeof(v) // -V.resize ( -);D.resize ( -);cout sizeof(d) // -cout sizeof(v) //24//bool *p = v[0];//cannot compileWayWithout reading the source code, can the external black box test prove that vectorC + + Exercise records 2---effective vector

C ++ standard STL-sgi stl source code learning notes (05) stl_vector and some issues refined 1C ++ standard STL-sgi stl source code

Part 1ArticleStl_deque's design philosophy and STL memory management are explained in a rough way. At least we can see the tip of the iceberg. In this article, I will refine the analysis of vector and analyze some functions in detail. In some cases, it is better to clarify some problems. Open the source code of stl_vector and find that the design idea of the vector is exactly the same as that of stl_deque. It is reasonable to think about it

C ++ Standard Stl-sgi stl source code learning notes (03) STL template compilation check and partial special compilation check

As mentioned in the previous article, the Concepts Check in sgi stl is actually a feature that will be checked during compilation by using template class instantiation. sgi stl is widely used. Concepts Check, as mentioned earlier, is not mentioned here. in    Template features are divided into two types: 1. Absolute features 2. Some Features In this blog post, we mainly look at some special features. We s

Valid STL thread security features of STL containers

, the chance of non-Matching calls of getmutexfor and releasemutexfor is minimized. Such a class (actually a class template) is basically like this: Template The method of using a class (like Lock) to manage the resource lifetime (such as mutex) is usually calledInitialization upon resource acquisitionYou should be able to read it in any comprehensive C ++ teaching material. A good start is stroustrup's "The C ++ programming language", because stroustrup recommends this idiom, but you can also

Incomplete list of STL technical articles (STL learning User Guide)

Incomplete list of STL technical articles (STL learning User Guide) Author: winterSource: The best STL Learning Website Incomplete list of STL technical articles (STL learning User Guide) 1 STL getting started Tutorial:

Efficient use of STL and STL

Efficient use of STL and STLEfficient use of STL It is only a matter of choice, all of which are STL, And the write efficiency may be several times different;Be familiar with the following terms and use STL efficiently;When an object is large, the pointer container is created instead of the object container. 1)

C ++ STL programming (2)

As an indispensable part of the C ++ standard, STL should penetrate into the corners of the C ++ program. STL is not the darling of the lab, nor the decoration on the programmer's desk. Her excitement is not a flash. This tutorial aims to spread and popularize the basic knowledge of STL. If you can take this opportunity to do something as far as you can for

STL Learning Series II: Standard Template Library (STL) Introduction

This article for the post, because the original operation in Linux, I under the Vc6/7 debugging, made a partial modification! Note: All code is debugged under VC6/VC7! Standard Template Library (STL) Introduction Standard Template Library (STL) Introduction 0 preface. 1 Define a list 2 Insert an element into the list using the member functions of the list push_back and Push_front member functions of th

Total Pages: 15 1 2 3 4 5 .... 15 Go to: Go

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.