最近在加班;后續補上;
-----------------------------------------------------------------------------
筆記:
C++的六大部件除了Algorithm是function template,其它都是class template;
Iterator 有5種分類(搜索策略的不同):
Iterator適配器:istream_iterator
備注:課件種大量使用了typename,作為模板類型的關鍵字。
---------------------------------------------------------------------------------------
accumulate:累計計算,for_each():循環遍歷執行;
replace替換;countj計數和count_if條件計數;find查找和find_if條件查找。
-------------------------------------------------------------------------------------------
仿函數functors:struct functors_name{operator();}
----------------------------------------------------------------------------------------
適配器的實現方案:繼承和內含;
-------------------------------------------------------------------------------------------
函數適配器binder2nd
cout<<count_if(vi.begin(),vi.end(),notl(bind2nd(less<int>(),40)));
其中less<int>()是一個仿函數,通過int實例化,bind2nd( less<int>() ,40)是函數適配器,因為bind2nd的返回類型還是less<int>()類型,把仿函數的第二個參數綁定為40。bind2nd只是修改less<int>(),這個類型。
仿函數,迭代器必須能夠回答adaptator的提問,即adaptor可以操作仿函數的內部變量。
—————————————————————————————————
reverse_iterator:迭代器適配器
X 適配器:istream_iterator。
--------------------------------------------------------------------------------------------------