//#include "stdafx.h"
#include #include #include #include using namespace std;
#include #include #include //find the first instance in s_array of any characters in to_find
int main(int argc, char* argv)
; string to_find = ;
// returns first occurrence of "ee" -- &s_array[2]
string *found_it = find_first_of( s_array, s_array+6,
to_find, to_find+3 );
// generates:
// found it: ee
// &s_array[2]: 0x7fff2dac
// &found_it: 0x7fff2dac
if ( found_it != &s_array[6] )
vector< string> svec( s_array, s_array+6);
vector< string > svec_find( to_find, to_find+3 );
// returns occurrence of "oo" -- svec.end()-2
vector< string>::iterator found_it2;
found_it2 = find_first_of(svec.begin(), svec.end(),
svec_find.begin(), svec_find.end(), equal_to() );
// generates:
// found it, too: oo
// &svec.end()-2: 0x100067b0
// &found_it2: 0x100067b0
if ( found_it2 != svec.end() )
return 0;}/*
templateinline
_fi1 find_first_of(_fi1 _f1, _fi1 _l1, _fi2 _f2, _fi2 _l2) */
/*templateinline
_fi1 find_first_of(_fi1 _f1, _fi1 _l1, _fi2 _f2, _fi2 _l2,
_pr _p) */
泛型演算法系列37 堆演算法
1。概念 堆是一種特殊的二叉樹,具備以下兩種性質 1 每個節點的值都大於 或者都小於,稱為最小堆 其子節點的值 2 樹是完全平衡的,並且最後一層的樹葉都在最左邊 這樣就定義了乙個最大堆。2。堆可以用乙個陣列表示,有如下性質 heap i heap 2 i 1 其中0 i n 1 2 heap i h...
泛型演算法系列6 find find if
include stdafx.h include include include include include include include using namespace std class ourfriends static void friendset const string fs,in...
每日演算法系列 7
建立三個指標,分別指著head前乙個結點pre,head,head後乙個結點next。初始化pre,使得pre先指著位於鍊錶頭部外部空間,設為null,next也設為null但並不存在指向者。首先先將next指向head.next,用於儲存head的下乙個結點,使得鍊錶轉向不會因為鍊錶斷裂而丟失he...