Standard library type

简介:   Key types: string, vector, bitset, companion type       string s1; string s2(s1); string s3("value"); string s4(n,'...

 

Key types: string, vector, bitset, companion type

 

 

 

string s1;

string s2(s1);

string s3("value");

string s4(n,'c');

 

 

string line;

while(getline(cin, line))

cout<<line<<endl;

 

string s;

s.empty()

s.size()

s[n]

S1+s2

S1=s2

V1==v2

!=, <, <=,

>, >=

 

string::size_type

for(string::size_type ix=0;ix!=str.size();++ix)

str[ix]='*';

 

isalnum(c)

isalpha(c)

iscntrl(c)

isdigit(c)

isgraph(c)

islower(c)

isprint(c)

ispunct(c)

isspace(c)

isupper(c)

isxdigit(c)

tolower(c)

toupper(c)

 

Vector

Class template

#include <vector>

using std::vector;

 

vector<T> v1;

vector<T> v2(v1);

vector<T> v3(n, i);

vector<T> v4(n);

 

v.empty()

v.size()

v.push_back(t)

v[n]

v1=v2

V1==v2

!=, <, <=, >, >=

-------------------------------------------------------------------------------------------------

#include "stdafx.h"

#include <vector>

using std::vector;

#include <iostream>

using std::cin;

using std::cout;

 

int _tmain(int argc, _TCHAR* argv[])

{

vector<int> ivec;

for(vector<int>::size_type i=0;i<=10;++i)

ivec.push_back(i);

 

for(vector<int>::size_type ix=0;ix<=10;++ix)

cout<<ivec[ix];

cout<<"/r/n";

 

for(vector<int>::iterator iter=ivec.begin();

iter != ivec.end();

++iter)

cout<<*iter;

 

cout<<"/r/n";

vector<int>::iterator mid=ivec.begin()+ivec.size()/2;

cout<<*mid;

 

int x;

cin>>x;

return 0;

}

------------------------------------------------------------------------------------------------

 

#include <bitset>

using std::bitset;

bitset<n> b;

bitset<n> b(unsigned_long_variable);

bitset<n> b(string_object);

bitset<n> b(string_object, pos, n);

 

b.any()

b.none()

b.count()

b.size()

b(pos)

b.test(pos)

b.set()

b.set(pos)

b.reset()

b.reset(pos)

b.flip()

b.flip(pos)

b.to_ulong()

os<<b

 

bitset<32> bitvec2(0xffff);

cout<<"bitvec2:"<<bitvec2<<endl;

 

Terminology:

abstract data type

bitset

cctype header

class template

container

difference_type

empty

getline

high-order

index

iterator

iterator arithmetic

low-order

off-the-end iterator

push_back

sentinel

size

size_t

size_type

using declaration

value initialization

++operator

::operator

[]operator

*operator

<<operator

>>operator

目录
相关文章
|
并行计算 C++ 异构计算
cuda中关于占用率的计算
cuda中关于占用率的计算
307 0
08 # 接口:函数类型接口
08 # 接口:函数类型接口
139 0
|
PHP
PHP 文件加载简单使用
PHP 文件加载简单使用
183 0
|
SQL 存储 缓存
《CDP企业数据云平台从入门到实践》——Hive3 新特性 (1)
《CDP企业数据云平台从入门到实践》——Hive3 新特性 (1)
332 0
|
算法 双11
通俗理解决策树中的熵&条件熵&信息增益
参考通俗理解决策树算法中的信息增益 说到决策树就要知道如下概念: 熵:表示一个随机变量的复杂性或者不确定性。 假如双十一我要剁手买一件衣服,但是我一直犹豫着要不要买,我决定买这件事的不确定性(熵)为2.6。
906 0
|
大数据 内存技术 C++
十个Flex/Air疑难杂症及解决方案简略
十个Flex/Air疑难杂症及解决方案简略 转自http://blog.sban.us/40.html 最近去一家台企,对方给我出了十道“难道”:在TileList中如果選擇檔過多,會出現捲軸,當拖動捲軸時,渲染的進度條會出現花屏現象;简体:在TileList中如果选择档过多,会出现卷轴,当...
How to determine if a machine is localhost?
 Dns.GetHostEntry(remote).HostName == Dns.GetHostEntry(“localhost”).HostName
712 0
|
18天前
|
存储 弹性计算 人工智能
【2025云栖精华内容】 打造持续领先,全球覆盖的澎湃算力底座——通用计算产品发布与行业实践专场回顾
2025年9月24日,阿里云弹性计算团队多位产品、技术专家及服务器团队技术专家共同在【2025云栖大会】现场带来了《通用计算产品发布与行业实践》的专场论坛,本论坛聚焦弹性计算多款通用算力产品发布。同时,ECS云服务器安全能力、资源售卖模式、计算AI助手等用户体验关键环节也宣布升级,让用云更简单、更智能。海尔三翼鸟云服务负责人刘建锋先生作为特邀嘉宾,莅临现场分享了关于阿里云ECS g9i推动AIoT平台的场景落地实践。
【2025云栖精华内容】 打造持续领先,全球覆盖的澎湃算力底座——通用计算产品发布与行业实践专场回顾