![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
STL
enjoy嚣士
一个行走在键盘上的修理工
展开
-
c++ STL 之 string
template<class T>void print_elemnt(T &v){ for(auto i : v) cout<<i<<" "; cout<<endl;}void test_string(){ /* string的本质,处理utf-8字符 typedef basic_string<char&..原创 2019-02-18 11:43:37 · 217 阅读 · 0 评论 -
STL需要注意的一些问题(二)
7.map查找key是否存在的方法1.使用find方法查看key是否存在,使用查找后的结果前必须判断是否查找到。2.如果只是判断key是否存在,可以使用count方法,返回1,存在;返回0,不存在8.string类find方法,查找后需要判断是否等于string::npos9.std::sort排序方法注意问题sort排序部分源码...while (__comp(*__f...原创 2019-04-22 17:51:06 · 118 阅读 · 0 评论 -
C++ STL 介绍
一、一般介绍&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STL(Standard Template Library),即标准模板库,是一个具有工业强度的,高效的C++程序库。它被容纳于C++标准程序库(C++ Standard Library)中,是ANSI/ISO C++标准中最新的也是极具革命性的一部分。该库包含了诸多在计算机科学领域里所常用的基本数据结构和基本算法转载 2019-02-18 10:23:46 · 220 阅读 · 0 评论 -
c++ STL 之 unorder_map及unorder_set使用自定义类作为key的方法
#include <iostream>#include <string>#include <unordered_map>#include <unordered_set>using namespace std;struct RECT { int width; int height;public: RECT(int a, i...原创 2019-02-19 18:38:49 · 2227 阅读 · 0 评论 -
c++ STL queue及priority_queue
#include <iostream>#include <stack>#include <queue>#include <functional>using namespace std;#define VNAME(value) {cout<<(#value)<<":"<<end原创 2019-02-19 18:39:09 · 214 阅读 · 0 评论 -
c++ STL 之 stack
#define VNAME(value) {cout<<(#value)<<":"<<endl;}void print_stack(stack<int> v){ while (!v.empty()) { cout<<v.top()<<" "; v.pop(); } cout&原创 2019-02-19 18:39:29 · 106 阅读 · 0 评论 -
c++ STL 之 map及multimap
#define VNAME(value) {cout<<(#value)<<":"<<endl;}template<class T>void print_map(T &v){ for (auto tmp : v) { cout<<"key:"<<tmp.first原创 2019-02-19 18:38:26 · 270 阅读 · 0 评论 -
c++ STL 之 set及multiset
/**template < class T, // set::key_type/value_typeclass Compare = less<T>, // set::key_compare/value_compareclass Alloc = allocator<T> // set::allocator_t...原创 2019-02-18 11:44:38 · 235 阅读 · 0 评论 -
c++ STL 之 vector
void test_vector(){ int h[] ={1,2,3,4,5}; vector<int> a(h,h+5); vector<int> b(a.begin(),a.begin()+3); //使用迭代器初始化[,) vector<int> c(3,4); //初始化3个4 vector<int> d(b); //拷贝...原创 2018-09-03 15:40:16 · 92 阅读 · 0 评论 -
c++ STL 之 array
#define VNAME(value) {cout<<(#value)<<":"<<endl;}template<class T>void print_elemnt(T &v){ for(auto i : v) cout<<i<<" "; cout<原创 2019-02-18 11:44:24 · 1084 阅读 · 0 评论 -
c++ STL 之 deque
#define VNAME(value) {cout<<(#value)<<":"<<endl;}template<class T>void print_elemnt(T &v){ for(auto i : v) cout<<i<<" "; cout<原创 2019-02-18 11:44:12 · 153 阅读 · 0 评论 -
c++ STL 之 List
#define VNAME(value) {cout<<(#value)<<":"<<endl;}template<class T>void print_elemnt(T &v){ for(auto i : v) cout<<i<<" "; cout<&a原创 2019-02-18 11:43:52 · 234 阅读 · 0 评论 -
STL需要注意的一些问题(一)
1. STL之当结构体作为map,set容器的key时需要注意些什么?首先要清楚map,set是有序的,即插入时就有序了。那么首先要确保结构体可以比较大小。先来一段代码。#include <iostream>#include <string>#include <map>using namespace std;struct Info{ strin...原创 2019-04-19 17:59:33 · 352 阅读 · 0 评论