SortedDictionary<TKey,TValue>.Enumerator 構造体

定義

SortedDictionary<TKey,TValue> の要素を列挙します。

public: value class SortedDictionary<TKey, TValue>::Enumerator : System::Collections::Generic::IEnumerator<System::Collections::Generic::KeyValuePair<TKey, TValue>>, System::Collections::IDictionaryEnumerator
public struct SortedDictionary<TKey,TValue>.Enumerator : System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<TKey,TValue>>, System.Collections.IDictionaryEnumerator
type SortedDictionary<'Key, 'Value>.Enumerator = struct
    interface IEnumerator<KeyValuePair<'Key, 'Value>>
    interface IEnumerator
    interface IDisposable
    interface IDictionaryEnumerator
type SortedDictionary<'Key, 'Value>.Enumerator = struct
    interface IEnumerator<KeyValuePair<'Key, 'Value>>
    interface IDisposable
    interface IDictionaryEnumerator
    interface IEnumerator
type SortedDictionary<'Key, 'Value>.Enumerator = struct
    interface IEnumerator<KeyValuePair<'Key, 'Value>>
    interface IDisposable
    interface IEnumerator
    interface IDictionaryEnumerator
type SortedDictionary<'Key, 'Value>.Enumerator = struct
    interface IEnumerator<KeyValuePair<'Key, 'Value>>
    interface IDictionaryEnumerator
    interface IEnumerator
    interface IDisposable
type SortedDictionary<'Key, 'Value>.Enumerator = struct
    interface IEnumerator<KeyValuePair<'Key, 'Value>>
    interface IDictionaryEnumerator
    interface IDisposable
    interface IEnumerator
Public Structure SortedDictionary(Of TKey, TValue).Enumerator
Implements IDictionaryEnumerator, IEnumerator(Of KeyValuePair(Of TKey, TValue))

型パラメーター

TKey
TValue
継承
SortedDictionary<TKey,TValue>.Enumerator
実装

注釈

foreach C# 言語のステートメント (for eachC++ では、Visual Basic) は、For Each列挙子の複雑さを隠します。 したがって、列挙子を直接操作するのではなく、foreach を使用することをお勧めします。

列挙子を使用すると、コレクション内のデータを読み取ることができますが、基になるコレクションを変更することはできません。

最初、列挙子はコレクションの先頭の要素の前に位置付けられます。 この位置では、Current が未定義です。 の値CurrentMoveNext読み取る前に、列挙子をコレクションの最初の要素に進めるメソッドを呼び出す必要があります。

このプロパティは Current 、呼び出されるまで MoveNext 同じオブジェクトを返します。 MoveNext は、Current を次の要素に進めます。

MoveNext がコレクションの末尾を通過した場合、列挙子がコレクション内の最後の要素の後に配置され、MoveNextfalse を返します。 列挙子がこの位置にある場合、後続の MoveNext 呼び出しも false を返します。 最後に返された呼び出しMoveNextfalseCurrent未定義の場合。 Current を、再度、コレクションの最初の要素に設定することはできません。列挙子の新しいインスタンスを作成する必要があります。

列挙子は、コレクションが変更されない限り有効です。 要素の追加、変更、削除などの変更がコレクションに対して行われた場合、列挙子は回復不能に無効になり、次の呼び出MoveNextIEnumerator.ResetしまたはスローがInvalidOperationException行われます。

列挙子はコレクションに排他アクセスできないため、コレクションの列挙処理は本質的にスレッド セーフな処理ではありません。 列挙処理でスレッド セーフを確保するには、列挙処理が終わるまでコレクションをロックできます。 コレクションに対し複数のスレッドがアクセスして読み取りや書き込みを行うことができるようにするには、独自に同期化を実装する必要があります。

System.Collections.Generic 名前空間のコレクションの既定の実装は同期されません。

プロパティ

Current

列挙子の現在位置の要素を取得します。

メソッド

Dispose()

SortedDictionary<TKey,TValue>.Enumerator によって使用されているすべてのリソースを解放します。

MoveNext()

列挙子を SortedDictionary<TKey,TValue> の次の要素に進めます。

明示的なインターフェイスの実装

IDictionaryEnumerator.Entry

列挙子の現在位置の要素を DictionaryEntry 構造体として取得します。

IDictionaryEnumerator.Key

列挙子の現在位置の要素のキーを取得します。

IDictionaryEnumerator.Value

列挙子の現在位置の要素の値を取得します。

IEnumerator.Current

列挙子の現在位置の要素を取得します。

IEnumerator.Reset()

列挙子を初期位置、つまりコレクションの最初の要素の前に設定します。

適用対象

こちらもご覧ください