
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
264
|
Chapter 4: Generics
get
{
return this.currentKey;
}
}
object IEnumerator.Current
{
get
{
if ((this.index == 0) || (this.index ==
(this._ReversibleSortedList.Count + 1)))
{
throw new InvalidOperationException(
"Enumeration operation could not occur");
}
return this.currentKey;
}
}
// Fields
private ReversibleSortedList<TKey, TValue> _ReversibleSortedList;
private TKey currentKey;
private int index;
private int version;
}
#endregion //ReversibleSortedListKeyEnumerator definition
#region ReversibleSortedListValueEnumerator definition
[Serializable]
private sealed class ReversibleSortedListValueEnumerator : IEnumerator<TValue>,
IDisposable,
IEnumerator
{
// Methods
internal ReversibleSortedListValueEnumerator(
ReversibleSortedList<TKey, TValue> ReversibleSortedList)
{
this._ReversibleSortedList = ReversibleSortedList;
this.version = ReversibleSortedList.version;
}
public void Dispose( )
{
this.index = 0;
this.currentValue = default(TValue);
}
public bool MoveNext( )
{
if (this.version != this._ReversibleSortedList.version)
Example 4-3. ReversibleSortedList class (continued)