次の方法で共有


IIterator<T> interface

Supports iteration over a collection.

Template parameters

  • T
    The type of objects to iterate.

Members

The IIterator<T> interface inherits from IInspectable. IIterator also has these types of members:

  • Methods

Methods

The IIterator<T> interface has these methods.

Method Description
get_Current

Gets the current item in the collection.

get_HasCurrent

Gets a value that indicates whether there is a current item or the iterator is at the end of the collection.

MoveNext

Advances the enumerator to the next item in the collection.

 

Examples

The following code example demonstrates how to use the IIterator interface.

comptr<Folder> spFolder;
hr = GetKnownFolder(FOLDERID_MusicFolder, &spFolder);
//...
comptr<IVectorView<IShellItem2>> spItems;
hr = pFolder->GetItems(&spItems);
//...
comptr<IIterator<IShellItem2>> spIter;
hr = spItems->First(&spIter);
//...
bool hasCurrent;
for (hr = spIter->get_HasCurrent(&hasCurrent); 
     SUCCEEDED(hr) && hasCurrent; 
     hr = spIter->MoveNext(&hasCurrent))
{
    comptr<IShellItem2> spAnItem;
    hr = spIter->get_Current(&spAnItem)
    //...
}

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Header

Windows.Foundation.Collections.h

See also

IIterable