
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Reversing the Contents of a Sorted List
|
249
return this.keys[index];
}
private KeyList<TKey, TValue> GetKeyListHelper( )
{
if (this.keyList == null)
{
this.keyList = new KeyList<TKey, TValue>(this);
}
return this.keyList;
}
private ValueList<TKey, TValue> GetValueListHelper( )
{
if (this.valueList == null)
{
this.valueList = new ValueList<TKey, TValue>(this);
}
return this.valueList;
}
private void Insert(int index, TKey key, TValue value)
{
if (this._size == this.keys.Length)
{
this.EnsureCapacity(this._size + 1);
}
if (index < this._size)
{
Array.Copy(this.keys, index, this.keys, (int)(index + 1),
(int)(this._size - index));
Array.Copy(this.values, index, this.values, (int)(index + 1),
(int)(this._size - index));
}
this.keys[index] = key;
this.values[index] = value;
this._size++;
this.version++;
}
private void InternalSetCapacity(int value, bool updateVersion)
{
if (value != this.keys.Length)
{
if (value < this._size)
{
throw new ArgumentOutOfRangeException(
"value", "Too small capacity");
}
if (value > 0)
{
TKey[] localArray1 = new TKey[value];
Example 4-3. ReversibleSortedList class (continued)