c stl cookbook

Alibabacloud.com offers a wide variety of articles about c stl cookbook, easily find your c stl cookbook information here online.

STL introduction (introduction to the standard template library)

It took me one night to translate an article about STL.Article. The first time I translated this kind of things, I felt that computer books are still better at the original English version, because many concepts cannot be properly expressed in Chinese (it's just that they can't be said ,:-)). Thanks to the first translation, the level must be relatively good. The key is that STL has never been seen before and is unfamiliar, so it is very hard to trans

Introduction to C + + Standard Template Library (STL)

1. STL Basic IntroductionThe C + + STL (Standard Template Library) is a set of powerful C + + template classes, collectively known as a series of software developed by HP Labs. The purpose of the STL is to standardize the components so that they do not have to be re-developed so that the latter can use the ready-made components, and the open source components are

STL (Standard Template Library) Theory Foundation, container, iterator, algorithm

Basic conceptsThe STL (Standard Template Library) is a generic term for a range of software developed by HP Labs. It is now mostly in C + +, but the technology has been around for a long time before being introduced to C + +.STL is broadly divided into three categories: algorithm (algorithm), container (container), and iterator (iterators), and containers and algorithms can be seamlessly connected through i

Iterator for STL components (1)

STLAn important feature is the separation of data structures and algorithms. Although this is a simple concept, this separation does make STL very common. For example, because STL's sort () function is completely universal, you can use it to operate almost any data set, including linked lists, containers, and arrays. Key Points STL algorithms are provided as template functions. To be different from other co

About MFC and the use of STL

Problem: I read about STL in several different places, but I still don't know if I am using STL or MFC in my application. My program also deals with string,vectors and other things. What's the difference between using STL and MFC? Answer: To answer, "which one should I use?" "The answer to this question is almost the same. It depends on what you want to do, th

Three major issues of STL in server program development

When I asked some friends from the same company about the serverProgramWhen using STL in, they all answered in their own company's server program development, generally not using STL.Why is the standard library unpopular in the server program development environment? I think STL has three major problems in a highly stable, high-performance, and high-concurrency environment like server programs. Question 1:

C + + must be aware of (iv) STL

The short description of the STL (Standard Template Library) is not enough to reflect its design prowess, and the following text is merely an "appetizer" that encourages you to delve into the STL. STL is not only a library, it is an excellent idea as well as a set of conventions. STL contains three main components: co

"STL" "HDU2024" C language Legal identifier "water problem"

#include 8#include 9#include string>Ten#include One#include A#include -#include -#include the#include -#include - - using namespacestd; + - #definell Long Long + #defineMax3 (a,b,c) Fmax (A,fmax (b,c)) A #defineiOS Ios_base::sync_with_stdio (false); Cin.tie (0); Cout.tie (0); at - Const intMAXN = the; - Const intINF =0x3f3f3f3f; - - BOOLcmpConst inta,Const intb) - { in returnA>b; - } to + - intMain () the { * intN; $scanf"%d",n);Panax Notoginseng GetChar (); - while(n--

C + + STL (2)

for_each (V.begin (), V.end (), [] (int2{3 " ) " 4 }(3)1 for (int2{3 ""; 4 }String uppercase to lowercase:1#include"stdafx.h"2#include 3#include 4#include string>5#include 6 using namespacestd;7 intMain ()8 {9 stringS1 ="Hello world.";Ten stringS2; OneTransform (S1.begin (), S1.end (), S2.begin (), toupper);//same capitalization to lowercase is tolower Acout Endl; -}Two-point search:1#include"stdafx.h"2#include 3#include 4#include string>5#include 6 using namespacestd;7

Translation C + + STL container Reference Manual (chapter I <array>)

Max_ Size represents the capacity of the container, and they may be different. Access to elements Operator[] Access Element (public member function) At Access Element (public member function) Front access the first element (public member function) Back access t

C++11 STL Atomic_flag Sample

Author:drivermonkeyMail:[email protected]phone:13410905075qq:196568501Test environment: Win7 bitCompiler: GCC 4.81Test code-/********************************************************************************* Copyright (C), 1988-1999, Drvivermonkey. Co., Ltd. File name:Author:Driver Monkey version:mail:[emailprotected] date:2014.04.02 description:test std Lib Automic_flag *********************************************************************************/#include The above code executes the result:S

Two implementations of the heap (arrays and STL)

+ - inti =0;//swap down from the root + whileI2+1//maybe only one son . A intA = i *2+1, B = i *2+2;//number of two sons at if(b //if the right son exists and the value is smaller than the left son, swap - if(Heap[a] >= x) Break;//If you can't swap, quit . -Heap[i] = Heap[a];//bring up the values of your son. -I=A; - } -Heap[i] =x; in returnret; - } to + intMain () - { thePush1); *Push2); $PushTen);Panax NotoginsengPush7); -Push4); the + intX1 =po

STL container types do not use references in C + + cause program efficiency to degrade

Recent brush algorithm problems, found a problem:I am implementing an algorithm recursively, but in the function TreeNode * createtree(vector, int left, int. right)At first, TreeNode * createtree (vector, int left, and int right) were used, and the result always timed out,On the internet to find some other people to write the algorithm, found that the realization is that, and finally found that the function of the parameter type is different,When others use the vector type to do arguments, pass

The main algorithm in STL (I.)

sub-sequence that matches a sequence. For example, the following two function prototypes are searched in the iterator interval [First1, last1) to match the iterator interval [first2, last2] element, returning the first element of the iterator or last1.Function Prototypes: Template class ForwardIterator1, class forwarditerator2> ForwardIterator1 Find_end ( ForwardIterator1 _first1, ForwardIterator1 _last1, ForwardIterator2 _first2, ForwardIterator2 _last2 ); Template class Fo

Use of queues in C + + STL

Queue, as in example: Q.push (x); Connect X to the end of the queue.Out of the team, as in Example: Q.pop (); The first element of the popup queue, note that the value of the popup element is not returned.Access the first element of the team, such as: Q.front (), which is the first element to be pressed into the queue.Access the tail element, such as: Q.back (), which is the element that was last pressed into the queue.Determine if the queue is empty, as in example: Q.empty (), returns True when

Basic operation of C + + STL set

], no return value * //4,void Clear () to remove all elements within the set container $Set_int.erase (3);Panax Notoginseng print (set_int); - the //Element Lookup + //count (value) returns the number of elements within the set object that have the value of the element A //iterator Find (value) returns the location of value where value will be returned to end () the //Lower_bound (value), Upper_bound (value), Equal_range (value) + Setint>:: iterator it; -It=set_int.find (

C + + STL list container member functions

default, is generally sequential, such as Integer, string comparison is ASCII code. void L.splice (It pos, list x)void L.splice (It pos, list x, it i)void L.splice (It pos, list x, it first, it last) To "cut" all the elements in the list x to the pos , it is simply a pointer operation, without assigning a value. The element iin the chain table x is"clipped" to the pos , just a single element. Migrate the elements from first to last in the list x to pos in l Place. These acti

C + + Common STL Summary

Vector一个和数组类似的向量容器,除了数组的功能外还可以在尾部插入元素,可完全代替数组。vector是在堆中分配内存,元素连续存放,在插入和删除时会造成内存块的copy。Header file#include Created with an initial value of 0. vectorAssign value //直接赋值(和数组用法一样) v[i]=value; //尾部扩张(每使用一次容器容量增加1) v.push_back(date);Access //下标访问同数组 //迭代器访问 vector插入(自动扩张容器一个元素空间) v.insert(v.begin()+n,date);//在指针位置插入date v.insert(v.end()-n,date);//在指针位置插入dateDelete v.clear(); //删除所有素同时元素空间置为o v.erase(v.begin()+n);//删除指针指向元素并删除这个元素空间 v.erase(v.end()-n);//删除指针指

C++11 STL Learning Pair

elements ofthe tuple to the constructor Offoo:pairint, foo> p2 (piecewise_construct, Make_tuple ( the), t);}voidpairreftest () {inti =0; Auto P= Make_pair (i, i); ++P.first; ++P.second; cout"When use ' ' I:"Endl; Auto P1= Make_pair (ref(i),ref(i)); ++P1.first; ++P1.second; cout"When use ' ref () ' I:"Endl;}voidTietest () {pairChar,Char> P = Make_pair ('x','y');//pair Oftwo chars CharC; Tie (Ignore, c)= P;//extract second value into C (Ignore first one)cout Endl; Tie (c, ignore)=p; coutEndl;

STL Container (iii)--sort map

STL Container (iii)--sort mapFor the sorting problem of map, it is divided into two parts: Sort by key and sort by value. Let's say the following separately ~1. Sort by KeyThe map is sorted by key by default in ascending order, regardless of the sequence entered. If the numeric type of int/double is key, then it is arranged by size, and if it is a string, it is arranged in the dictionary order of the Strings ~ (Do you remember the dictionary order you

Total Pages: 15 1 .... 10 11 12 13 14 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.