原创 STL算法之sort和stable_sort

1.stable_sort 和 sort的區別在於 前者作排序可以使原來的"相同"的值在序列中的相對位置不變如 1 4 6 7 4' (4 和 4'值相等,加上' 表示是2個元素)那麼stable_sort能保證排序完 4 仍然在4' 前

原创 C++的count和cout_if函數

count_if函數原型如下: [cpp] view plain copy  print? template<class _InIt, class _Pr> inline       typename iterator_tr

原创 C++ STL算法transform

參考:《C++ Primer》以及教學視頻 所有容器適用 transform(b1,e1,b2,op)      //把一個區間[b1,e1)內的數據經過(op)轉化,放入第二個容器內                  

原创 STL算法,堆排序

/***************************************** STL-算法--Heap算法 堆排序算法 (heapsort) make_heap()         //把容器內的數據做堆排序 push_h

原创 C++之STL bitset

有些程序要處理二進制位的有序集,每個位可能包含的是0(關)或1(開)的值。位是用來保存一組項或條件的yes/no信息(有時也稱標誌)的簡潔方法。標準庫提供了bitset類使得處理位集合更容易一些。要使用bitset類就必須要包含相關的頭文

原创 函數對象

一個函數對象,即一個重載了括號操作符“()”的對象。當用該對象調用此操作符時,其表現形式如同普通函數調用一般,因此取名叫函數對象。舉個最簡單的例子: [cpp] view plain copy class FuncObj

原创 C++的substr函數的用法

C++中substr函數的用法 #include<string> #include<iostream> using namespace std; main() { string s("12345asdf"); string a=s.sub

原创 C++的STL之search_n

       C++STL的非變易算法(Non-mutating algorithms)是一組不破壞操作數據的模板函數,用來對序列數據進行逐個處理、元素查找、子序列搜索、統計和匹配。       重複元素子序列搜索search_n算

原创 C++ STL之map和multimap用法

一. Map與 Multimap 特點 Map 和 Multimap 將(key/value) 一組當做元素,它們可以根據 key 的排序準則自動將元素排序。 Multimap允許重複元素,map不允許重複。 類型定義:

原创 STL算法排列

《C++ Primer》 //所有容器適用 next_permutation(b,e)       //下一個排列-----從小到大   返回值false,表示沒有下一個 next_permutation(b,e,cp) prev_pe

原创 STL算法reverse,reverse_copy

/**------http://blog.csdn.net/u010579068------**/ #include<iostream> #include<cstdio> #include<string> #include

原创 C++的find和find_if函數

一、find()算法 [cpp] view plain copy  print? template<class InputIterator, class T>     InputIterator find ( Inp

原创 C++的STL模板的adjacent_find()

adjacent_find         //用來查找連續兩個相等的或者符合方法的 #include<iostream> #include<cstdio> #include<string> #include <vector>

原创 C++的STL算法for_each

for_each()函數將調用者提供的操作施加於每一個元素身上。它既可以是非變動性算法,也可以說是變動性算法。 [cpp] view plain copy  print? template <class InputI

原创 C++的STL之search()與find_end()

1、search() search(ideq.begin(),ideq.end(), ilist.begin(), ilist.end()); 2、find_end() find_end(ideq.begin(), ideq.end(),