\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Zoupers} \pdfinfo{ /Title (c-stl.pdf) /Creator (Cheatography) /Author (Zoupers) /Subject (C++ STL Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{5E5E5E} \definecolor{LightBackground}{HTML}{F4F4F4} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{C++ STL Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Zoupers} via \textcolor{DarkBackground}{\uline{cheatography.com/129178/cs/30896/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Zoupers \\ \uline{cheatography.com/zoupers} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 10th March, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{2.73735 cm} x{2.23965 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{迭代器基本操作}} \tn % Row 0 \SetRowColor{LightBackground} ++p, p++, *p & 前向迭代器 \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} -{}-p, p-{}- & 双向迭代器 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} p+=i, p-=i, p+i, p-i, p{[}i{]} & \seqsplit{随机访问迭代器} \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{迭代器分正向和反向,对反向进行++,迭代器指向前一个元素}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.78712 cm} x{2.18988 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Array容器}} \tn % Row 0 \SetRowColor{LightBackground} std::array\textless{}char,50\textgreater{}addr\{"hello"\} & 初始化 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} begin()/end() & \seqsplit{返回正向迭代器} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} cbegin()/cend() & \seqsplit{返回常量正向迭代器} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} rbegin()/rend() & \seqsplit{返回反向迭代器} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} crbegin()/crend() & \seqsplit{返回常量反向迭代器} \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} values{[}i{]}, values.at(i), get\textless{}n\textgreater{}(*) & \seqsplit{访问单个元素} \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} values.size() & \seqsplit{返回元素个数(size\_t)} \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} values.empty() & \seqsplit{判断容器是否有元素} \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{该容器内存储的所有元素一定会位于连续且相邻的内存中,无法扩展或者收缩}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.58804 cm} x{2.38896 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Vector容器}} \tn % Row 0 \SetRowColor{LightBackground} std::vector\textless{}double\textgreater{} values(N, V); & 初始化 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} begin()/end(),rbegin()/rend() & 同Array \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} size(),empty() & 同Array \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} capacity() & 返回当前容量 \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} front() & \seqsplit{返回第一个元素的引用} \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} resize() & \seqsplit{改变实际元素个数} \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} back() & \seqsplit{返回最后元素的引用} \tn % Row Count 12 (+ 2) % Row 7 \SetRowColor{white} reserve(N) & 增加容量到N \tn % Row Count 13 (+ 1) % Row 8 \SetRowColor{LightBackground} push\_back(v),emplace\_back(v) & \seqsplit{在尾部添加一个元素} \tn % Row Count 15 (+ 2) % Row 9 \SetRowColor{white} insert(p,v), insert(p,n,v) & \seqsplit{在p前插入1/n个元素} \tn % Row Count 17 (+ 2) % Row 10 \SetRowColor{LightBackground} insert(p,first,last) & 插入元素{[}first,last) \tn % Row Count 19 (+ 2) % Row 11 \SetRowColor{white} insert(p,initlist) & \seqsplit{插入初始化列表},\{\}括着 \tn % Row Count 21 (+ 2) % Row 12 \SetRowColor{LightBackground} pop\_back() & 删除最后元素 \tn % Row Count 22 (+ 1) % Row 13 \SetRowColor{white} erase(p), erase(beg,end) & 删除p处或{[}beg,end) \tn % Row Count 24 (+ 2) % Row 14 \SetRowColor{LightBackground} remove(v) & \seqsplit{删除和v相等元素} \tn % Row Count 26 (+ 2) % Row 15 \SetRowColor{white} clear() & 删除所有元素 \tn % Row Count 27 (+ 1) % Row 16 \SetRowColor{LightBackground} shrink\_to\_fit() & \seqsplit{将容量缩减至合适} \tn % Row Count 29 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{容量指不分配新内存当前能保存的最多元素个数}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Deque容器}} \tn % Row 0 \SetRowColor{LightBackground} std:deque\textless{}int\textgreater{} d(N,v) & 初始化 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} emplace\_front(v) & \seqsplit{直接在头部生成元素} \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{其他方法基本同vector容器,除了reserve()和capacity()方法}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.09494 cm} x{3.88206 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{\seqsplit{List容器(双向链表容器)}}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{splice()} & \seqsplit{将一个list容器中的元素插入到另一个容器的指定位置} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{remove\_if()} & \seqsplit{删除容器中满足条件的元素} \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{unique()} & \seqsplit{删除相邻的重复元素,只保留一个} \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} merge() & \seqsplit{合并两个有序list容器,合并后仍然有序} \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} sort() & \seqsplit{更改容器中元素的位置,将他们进行排序} \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{reverse()} & \seqsplit{反转容器中元素的顺序} \tn % Row Count 13 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{不支持随机访问,其余方法同deque}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.53367 cm} x{1.44333 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Map容器}} \tn % Row 0 \SetRowColor{LightBackground} map\textless{}string,int\textgreater{} myMap\{\{"k1",1\},\{"k2",2\}\} & 初始化 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} count(k) & \seqsplit{查找键k个数} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} find(k) & \seqsplit{返回迭代器} \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{默认选择std::less\textless{}T\textgreater{}排序规则,升序排列 \newline 另外还有multimap,和map类似,但是可以同时存储多个键相同的键值对,但是multimap未提供at()成员方法,也没有重载{[}{]}运算符} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Multimap容器}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{和map类似,但是可以同时存储多个键相同的键值对,但是multimap未提供at()成员方法,也没有重载{[}{]}运算符} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{3.23505 cm} x{1.74195 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Set容器}} \tn % Row 0 \SetRowColor{LightBackground} set\textless{}string\textgreater{} myset & 初始化 \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{默认采用less\textless{}T\textgreater{}规则,升序排列;基本方法同map类似. \newline 另外还有multiset容器,不过可以储存多个相同的值.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.29402 cm} x{3.68298 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{unordered\_map容器}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{load\_factor()} & 返回当前负载因子 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} rehash(n) & \seqsplit{加那个底层使用桶数量设为n} \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{其他方法类似map函数} \newline 另外还有unordered\_multimap,同unordered\_map类似,但是可以存储多个键相等的键值对} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.83689 cm} x{2.14011 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{unordered\_set容器}} \tn % Row 0 \SetRowColor{LightBackground} unordered\_set\textless{}int\textgreater{} uset; & 初始化 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} insert(v)/emplace(v) & 添加元素 \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} erase(v) & \seqsplit{删除指定元素} \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{不能修改元素,无法随机访问} \newline 另外还有unordered\_multiset,同unordered\_set类似,但是可以同时存储多个值相同的元素} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{unordered\_multiset容器}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{同unordered\_set类似,但是可以同时存储多个值相同的元素}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.53827 cm} x{2.43873 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{stack容器适配器}} \tn % Row 0 \SetRowColor{LightBackground} stack\textless{}int, list\textless{}int\textgreater{}\textgreater{} my\_stack; & 初始化 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} empty(),size() & 同array \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} top() & \seqsplit{返回栈顶,为空则报错} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} push(v)/emplace(v) & 将v压入栈顶 \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} pop() & 弹出栈顶 \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} swap(other\_stack) & \seqsplit{和另一个栈互换} \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{默认封装了deque\textless{}T\textgreater{},互换栈时需要存储元素类型和底层基础容器} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.89126 cm} x{3.08574 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Queue容器适配器}} \tn % Row 0 \SetRowColor{LightBackground} std::queue\textless{}int\textgreater{} values; & 初始化 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{values.push(elem)} & \seqsplit{以移动方法在尾部添加元素} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{values.emplace(elem)} & \seqsplit{直接在queue尾部添加一个元素} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} values.pop() & \seqsplit{删除queue中的第一个元素} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} values.front() & 返回第一个元素 \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} values.back() & \seqsplit{返回最后一个元素} \tn % Row Count 10 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{和stack一样,queue也没有迭代器,访问元素的唯一方式是不断的移除访问过的元素。}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{\seqsplit{priority\_queue容器适配器}}} \tn % Row 0 \SetRowColor{LightBackground} priority\_queue\textless{}int\textgreater{} values; & \seqsplit{初始化,默认大根堆} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} values.push(elem) & 添加元素 \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{values.emplace(elem)} & 添加元素 \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} values.pop() & \seqsplit{移除第一个元素} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} values.top() & \seqsplit{返回第一个元素} \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{priority\_queue也没有迭代器,默认的比较函数是less,可以使用greater初始化为小根堆}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{迭代器适配器}} \tn % Row 0 \SetRowColor{LightBackground} reverse\_iterator & \seqsplit{反向迭代器,又称逆向迭代器} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{inserter或者insert\_iterator} & 安插型迭代器 \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{istream\_iterator/ostream\_iterator} & 流迭代器 \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{istreambuf\_iterator/ostreambuf\_iterator} & 流缓冲迭代器 \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} move\_iterator & 移动迭代器 \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{以上4中迭代器仅供参考,想要详细了解请自行查阅,另外还有迭代器辅助函数等。} \newline 这里提供一个参考网站,https://c.biancheng/view/7255.html} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{常用算法}} \tn % Row 0 \SetRowColor{LightBackground} sort(first, last) & 对{[}first, \seqsplit{last)范围内元素排序} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} stable\_sort(first, last) & 对{[}first, \seqsplit{last)内元素进行稳定排序} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} partial\_sort(first,middle,last) & 对{[}first,last)内元素选出middle-first个元素放在{[}first,middle)区间内 \tn % Row Count 9 (+ 4) % Row 3 \SetRowColor{white} \seqsplit{partial\_sor\_copy(first},last,result\_first,result\_last) & 筛选出result\_last-result\_first个元素排序并存储到{[}result\_first,result\_last) \tn % Row Count 14 (+ 5) % Row 4 \SetRowColor{LightBackground} is\_sorted(first,last) & 检测{[}first,last)范围内元素是否排好序,默认升序 \tn % Row Count 18 (+ 4) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{is\_sorted\_until(first,last)} \tn % Row Count 19 (+ 1) % Row 6 \SetRowColor{LightBackground} nth\_element(first,nth,last) & \seqsplit{nth左侧都比nth小,右侧都比nth大} \tn % Row Count 22 (+ 3) % Row 7 \SetRowColor{white} merge(first1,last1,first2,last2,result) & \seqsplit{有序合并有序序列至result} \tn % Row Count 24 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{inplace\_merge(first,middle,last)} \tn % Row Count 25 (+ 1) % Row 9 \SetRowColor{white} find(first,last,val) & 在{[}first,last)中找val第一次出现位置 \tn % Row Count 28 (+ 3) % Row 10 \SetRowColor{LightBackground} find\_if(first,last,pred) & \seqsplit{可以允许自定义规则} \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{常用算法 (cont)}} \tn % Row 11 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{find\_if\_not(first,last,pred)} \tn % Row Count 1 (+ 1) % Row 12 \SetRowColor{white} find\_end(first1,last1,first2,last2) & \seqsplit{找1中寻找2最后一次出现位置} \tn % Row Count 3 (+ 2) % Row 13 \SetRowColor{LightBackground} \seqsplit{find\_first\_of(first1},last1,first2,last2) & \seqsplit{找到1序列中2序列任意元素出现的首个位置} \tn % Row Count 6 (+ 3) % Row 14 \SetRowColor{white} \seqsplit{adjacent\_find(first},last) & \seqsplit{找到2个连续相等的元素} \tn % Row Count 8 (+ 2) % Row 15 \SetRowColor{LightBackground} search(first1,last1,first2,last2) & \seqsplit{在1中寻找2第一次出现位置} \tn % Row Count 10 (+ 2) % Row 16 \SetRowColor{white} search\_n(first,last,n,val) & \seqsplit{寻找val在连续出现n次的位置} \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\seqsplit{STL算法太多了...熟能生巧}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}