2021-06-23

函数整理

这篇文章是对我在学习工作中使用过的函数的一个整理,方便以后查阅。不定期更新。
格式为:函数名 - 语言,所属类
上次更新:2021-06-23
A
B
C
D
E
empty - C++, std::queue<T,Container>/#include<queue>
  格式:bool empty() const; (until C++20); [[nodiscard]] bool empty() const; (since C++ 20)
  参数列表:(none) - (无)
  返回值:true if the underlying container is empty, false otherwise - 如果容器为空则返回true,
      否则返回false
  时间复杂度:Constant - 常数级
  这个函数用于查看一个队列是否为空
  参考资料:
    cppreference - std::queue<T,Container>::empty
F
G
H
I
J
K
L
M
max(1)-C++, std::max/#include<algorithm>
  格式:

//until C++14
template< class T >
const T& max( const T& a, const T& b );
//since C++14
template< class T >
constexpr const T& max( const T& a, const T& b );

  参数列表:
     - a,b - 待比较的值
  返回值:返回a和b中较大的值,若a,b相等则返回a
  时间复杂度:常数级,只比较一次
  这个函数比较并返回a,b中较大的数
  参考资料:
    cppreference - std::max


memset-C++, std::memset/#include<cstring>
  格式:void* memset( void* dest, int ch, std::size_t count );
  参数列表:
     - dest - 指向待填充对象(起点)的指针
     - ch - 填充字节
     - count - 需要填充的字节数
  返回值:dest-指向填充完毕对象的指针,
  时间复杂度:
  这个函数按照子节对数组或其他对象进行填充。当ch为0时填充的全是0,当ch为其他值时可能
  会有出乎预料的结果
  参考资料:
    cppreference - std::memset
N
O
P
pop-C++, std::queue<T,Container>/#include<queue>
  格式:void pop();
  参数列表:(none)-(无)
  返回值:(none)-(无)
  时间复杂度:constant-常数级
  这个函数用于移除队首元素
  参考资料:
    cppreference - std::queue<T,Conatiner>::pop


push - C++, std::queue<T,Container>/#include<queue>
  格式:void push( const value_type& value );void push(value_type&& value); (since C++11)
  参数列表:value - the value of the element to push - 等待被传入队列的数据
  返回值:(none)-(无),
  时间复杂度:Amortized constant-平均时间为常数级
  这个函数用于将给定元素插入队列的末尾
  参考资料:
    cppreference - std::queue<T,Container>::push
Q
R
S
sort-C++, std::sort/#include<algorithm>
  格式:

//until C++20
template< class RandomIt >
void sort( RandomIt first, RandomIt last );
//since C++20
template< class RandomIt >
constexpr void sort( RandomIt first, RandomIt last );

//since C++17
template< class ExecutionPolicy, class RandomIt >
void sort( ExecutionPolicy&& policy, RandomIt first, RandomIt last );

//until C++20
template< class RandomIt, class Compare >
void sort( RandomIt first, RandomIt last, Compare comp );
//since C++20
template< class RandomIt, class Compare >
constexpr void sort( RandomIt first, RandomIt last, Compare comp );

//since C++17
template< class ExecutionPolicy, class RandomIt, class Compare >
void sort( ExecutionPolicy&& policy, RandomIt first, RandomIt last, Compare comp );

  参数列表:
     - first,last - 待排序数据的起点和终点
     - policy - 执行策略
     - comp - 自定义比较函数
  返回值:(none)-(无)
  时间复杂度:O(N·log(N))
  这个函数默认以非降序(non-descending)对[first,last)中的数据进行排序。如果comp没有缺省则
  按照comp进行排序。comp的格式应该为:

bool cmp(const Type1 &a, const Type2 &b);

  comp函数不可以对传入数据进行修改。policy为执行策略,分为顺序(sequenced_policy)、并
  行(parallel_policy)、并行无序(parallel_unsequenced_policy)、无序(unsequenced_policy)四种
  参考资料:
    cppreference - std::sort
    cppreference - excecution_policy
T
U
V
W
X
Y
Z
#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值