System::Collections::Generic::IEnumerator 클래스
IEnumerator class
일부 요소를 반복하는 데 사용할 수 있는 열거자 인터페이스입니다. 이 클래스의 객체는 System::MakeObject() 함수를 사용하여 할당해야 합니다. 스택에 이 타입의 인스턴스를 생성하거나 operator new를 사용하지 마십시오. 런타임 오류 및/또는 어설션 오류가 발생할 수 있습니다. 항상 이 클래스를 System::SmartPtr 포인터로 래핑하고, 해당 포인터를 함수 인자로 전달하십시오.
template<typename T>class IEnumerator : public virtual System::IDisposable,
public System::Details::EnumeratorBasedIterator<T>,
protected System::Details::IteratorPointerUpdater<T, false>
메서드
Typedefs
비고
#include <system/collections/list.h>
#include <system/smart_ptr.h>
using namespace System;
using namespace System::Collections::Generic;
int main()
{
// List 클래스 인스턴스를 생성합니다.
auto collection = MakeObject<List<int>>();
// 리스트를 채웁니다.
collection->Add(1);
collection->Add(2);
collection->Add(3);
// 목록의 열거자를 가져옵니다.
auto enumerator = collection->GetEnumerator();
while (enumerator->MoveNext())
{
// 현재 요소를 가져와서 출력합니다.
std::cout << enumerator->get_Current() << ' ';
}
// 열거자를 재설정합니다.
enumerator->Reset();
return 0;
}
/*
This code example produces the following output:
1 2 3
*/
또 보기