collection_adapter : BCLコレクションをSTL/CLRコレクション化する。
これによって begin(), end() の類が使えるので algorithm を適用できる。
#include <cliext/adapter> // collection_adapter
#include <cliext/vector> // vector
#include <cliext/algorithm> // find
using namespace System;
using namespace cliext;
using namespace System::Collections::Generic;
int main() {
array<String^>^ data = { L"one", L"two", L"three", L"four" };
List<String^> v(data);
// ListをSTL/CLR化したのが c
collection_adapter<IList<String^>> c(%v);
// begin(), end() が使えるので find に食わせられる
collection_adapter<IList<String^>>::iterator iter
= find(c.begin(), c.end(), gcnew String(L"three"));
// "three"以降を出力
while ( iter != c.end() ) {
Console::WriteLine(iter.get_ref()); // *iter ぢゃ駄目ポ
++iter;
}
return 0;
}