1,is_permutation 函数,判断其中一个序列是不是另外一个序列的全排列。

包括四个参数,前两个是第一个数组需要判断的起始位置和终止位置。后两个是第二个数组需要判断的起始位置和终止位置。

 #include<bits/stdc++.h>
using namespace std;
# define ll long long
# define inf 0x3f3f3f3f
const int maxn = 2e5+;
int main(){
int a[]={,,,,,,,};
int b[]={,,,,,,,};
int c[]={,,,,,,,};
int d[]={,,,,,,,};
int tmp;
tmp=is_permutation(a,a+,d,d+); //
cout<<tmp<<endl;
tmp=is_permutation(a,a+,d,d+); //
cout<<tmp<<endl;
tmp=is_permutation(a,a+,d,d+); //
cout<<tmp<<endl;
}

next_permutation 函数 和 prev_permutation函数的使用方法。

包括两个参数第一个是需要全排列的起始位置和终止位置。

next是求下一个大于原排列的新的排列。

prev是求下一个小于原排列的新的排列。

 #include<bits/stdc++.h>
using namespace std;
# define ll long long
# define inf 0x3f3f3f3f
const int maxn = 2e5+;
int main(){
int a[]={,,};
next_permutation(a,a+);
for(int i=;i<;i++){
cout<<a[i]<<" ";
}// 1 3 2
cout<<endl;
prev_permutation(a,a+);
for(int i=;i<;i++){
cout<<a[i]<<" ";
}// 1 2 3
cout<<endl;
}

equal_range函数。

这个函数综合的了两个函数,第一个返回的是小于等于val的(lower_bound),第二个返回的是大于val的(upper_bound).返回的是一个pair类型的。

返回的两个分别的下标对应的数。

数组:

 #include<bits/stdc++.h>
using namespace std;
# define ll long long
# define inf 0x3f3f3f3f
const int maxn = 2e5+;
int a[maxn];
int main(){
for(int i=;i<=;i++){
a[i]=i;
}
a[]=;
// 1 2 3 4 4 6 7 8 9 10
auto q=equal_range(a+,a++,);
cout<<a[q.first-a]<<endl;// 4
cout<<a[q.second-a]<<endl; // 6
return ;
}

vector

 #include<bits/stdc++.h>
using namespace std;
# define ll long long
# define inf 0x3f3f3f3f
const int maxn = 2e5+;
vector<int>q;
int main(){
q.push_back();
q.push_back();
q.push_back();
q.push_back();
q.push_back();
// 1 2 3 4 4 6 7 8 9 10
auto t=equal_range(q.begin(),q.end(),);
for_each(q.begin(),t.first,[](auto i){cout<<i<<" ";});// 1 2
cout<<*t.first<<endl;//3
cout<<*t.second<<endl;//
return ;
}

binary_search函数

查找当前有序区间是否存在val,如果有输出1,否则输出0

 #include<bits/stdc++.h>
using namespace std;
# define ll long long
# define inf 0x3f3f3f3f
const int maxn = 2e5+;
vector<int>q;
int main(){
q.push_back();
q.push_back();
q.push_back();
q.push_back();
q.push_back();
// 1 2 3 4 4 6 7 8 9 10
int tmp=binary_search(q.begin(),q.end(),);
cout<<tmp<<endl;// 1
tmp=binary_search(q.begin(),q.end(),);
cout<<tmp<<endl;// 0
return ;
}

STL之permutation/ equal_range/ binary_range学习的更多相关文章

  1. 《STL源码剖析》学习之traits编程

    侯捷老师在<STL源码剖析>中说到:了解traits编程技术,就像获得“芝麻开门”的口诀一样,从此得以一窥STL源码的奥秘.如此一说,其重要性就不言而喻了.      之前已经介绍过迭代器 ...

  2. stl源码剖析 详细学习笔记 算法总览

    //****************************基本算法***************************** /* stl算法总览,不在stl标准规格的sgi专属算法,都以 *加以标 ...

  3. stl源码剖析 详细学习笔记 set map

    // //  set map.cpp //  笔记 // //  Created by fam on 15/3/23. // // //---------------------------15/03 ...

  4. STL Stack(栈)学习笔记 + 洛谷 P1449 后缀表达式

    稍微看了看刘汝佳的白皮书,“实用主义”的STL实在是香到我了,而且在实验室大佬的推荐下我开始了stl的学习. 每篇附带一个题目方便理解,那行,直接开始. 毕竟是实用主义,所以就按照给的题目的例子来理解 ...

  5. stl源码剖析 详细学习笔记 空间配置器

    //---------------------------15/04/05---------------------------- /* 空间配置器概述: 1:new操作包含两个阶段操作 1>调 ...

  6. stl源码剖析 详细学习笔记 算法(4)

    //---------------------------15/03/31---------------------------- //lower_bound(要求有序) template<cl ...

  7. stl源码剖析 详细学习笔记 算法(1)

    //---------------------------15/03/27---------------------------- //算法 { /* 质变算法:会改变操作对象之值 所有的stl算法都 ...

  8. stl源码剖析 详细学习笔记 hashset hashmap

    //---------------------------15/03/26---------------------------- //hash_set { /* hash_set概述: 1:这是一个 ...

  9. stl源码剖析 详细学习笔记 hashtable

    //---------------------------15/03/24---------------------------- //hashtable { /* 概述: sgi采用的是开链法完成h ...

随机推荐

  1. css的简单学习笔记

    1.CSS的简介 *css :层叠样式表 **层叠: 一层一层. **样式表: 具有大量的属性和属性值 *使得页面的显示效果更加好. *css将网页内容和显示样式进行分离,提高了显示功能. *css不 ...

  2. python 装饰器的应用

    import time def test1(): print "hello\n" print test1.__name__ def test2(): print "hel ...

  3. (BFS) leetcode 690. Employee Importance

    690. Employee Importance Easy 377369FavoriteShare You are given a data structure of employee informa ...

  4. org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].Standard

    Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lan ...

  5. django中文学习资料

    Django 2.0 中文官方文档地址: https://docs.djangoproject.com/zh-hans/2.0/ <Django Girls>中文版地址: https:// ...

  6. webpack打包进内联html

    用到一个新插件:html-webpack-inline-source-plugin(依赖于html-webpack-plugin) 1.安装 npm i -D html-webpack-inline- ...

  7. Nginx简单手册

    Nginx 变量 变量名 注解 $arg_name 请求中的的参数名,即“?”后面的arg_name=arg_value形式的arg_name $args  请求中的参数值 $binary_remot ...

  8. zookeeper的搭建和简单的使用

    一.什么是zookeeper,有什么用 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,它是集群的管理者,监视着集群中各个节点的状态根据 ...

  9. springMVC的全局拦截器

    先说说为什么要使用springMVC的全局拦截器,比如 当我们在访问接口的时候,我们一般都会先判断这个用户是否登陆,我们就要在每个接口的前面都要判断一下,想想是不是很蛋疼,那工作量... 这时候,我们 ...

  10. 9.组合模式(Composite Pattern)

    动机(Motivate):    组合模式有时候又叫做部分-整体模式,它使我们树型结构的问题中,模糊了简单元素和复杂元素的概念,客户程序可以向处理简单元素一样来处理复杂元素,从而使得客户程序与复杂元素 ...