Nu/Nu.Math/OrderedDictionary.cs
/// <summary>
/// Inserts the given key/value pair at the specified index.
/// </summary>
/// <param name="index">The index to insert the key/value pair.</param>
/// <param name="key">The key to insert.</param>
/// <param name="value">The value to insert.</param>
/// <exception cref="System.ArgumentException">The given key already exists in the dictionary.</exception>
/// <exception cref="System.ArgumentNullException">The key is null.</exception>
/// <exception cref="System.ArgumentOutOfRangeException">The index is negative -or- larger than the size of the dictionary.</exception>
Inserts the given key/value pair at the specified index.
Inserts the given key / value pair at the specified index .
public void Insert(int index, TKey key, TValue value)
        {
            if (index < 0 || index > values.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(index), index, String.Empty);
            }
            dictionary.Add(key, index);
            for (int keyIndex = index; keyIndex != keys.Count; ++keyIndex)
            {
                var otherKey = keys[keyIndex];
                dictionary[otherKey] += 1;
            }
            keys.Insert(index, key);
            values.Insert(index, value);
            ++version;
        }
public void Insert ( int index , TKey key , TValue value ) { if ( index < 0 || index > values . Count ) { throw new ArgumentOutOfRangeException ( nameof ( index ) , index , String . Empty ) ; } dictionary . Add ( key , index ) ; for ( int keyIndex = index ; keyIndex != keys . Count ; ++ keyIndex ) { var otherKey = keys [ keyIndex ] ; dictionary [ otherKey ] += 1 ; } keys . Insert ( index , key ) ; values . Insert ( index , value ) ; ++ version ; }
Inserts the given key/value pair at the specified index.
Inserts the given key / value pair at the specified index .
The given key already exists in the dictionary.
The given key already exists in the dictionary .
The key is null.
The key is null .
The index is negative -or- larger than the size of the dictionary.
The index is negative - or - larger than the size of the dictionary .
index
int
The index to insert the key/value pair.
The index to insert the key / value pair .
key
TKey
The key to insert.
The key to insert .
value
TValue
The value to insert.
The value to insert .