src/NetStandard/Collections/Collections/src/Specialized/IndexDirectory.cs
/// <summary>
/// Inserts <paramref name="index"/> between <paramref name="index"/> - 1
/// and <paramref name="index"/> and will cause to move existing indexes at
/// <paramref name="index"/> by one.
/// </summary>
/// <param name="index">The to be inserted index.</param>
/// <param name="mode">The mode for the index.</param>
/// <returns>The index entry.</returns>
Inserts  between  - 1
and  and will cause to move existing indexes at
by one.
Inserts between - 1 and and will cause to move existing indexes at by one .
public IndexDirectoryEntry Insert(int index, IndexDirectoryEntryMode mode)
        {
            var entryListsCount = virtualizableLength;
            if (index >= entryListsCount) {
                return Add(index, mode);
            }
            var newLastIndex = entryListsCount;
            var indexEntry = new IndexDirectoryEntry(index, mode);
            entriesList.Insert(index, new Entries(new List<IndexDirectoryEntry>() { indexEntry }));
            virtualizableLength++;
            do {
                var entryList = entriesList[newLastIndex];
                if (!(entryList is null)) {
                    static void increaseEntryIndexesByOne(List<IndexDirectoryEntry> entries)
                    {
                        var entriesCount = entries.Count;
                        for (var entryIndex = 0; entryIndex < entriesCount; entryIndex++) {
                            entries[entryIndex].Index++;
                        }
                    }
                    increaseEntryIndexesByOne(entryList.NormalEntries);
                    increaseEntryIndexesByOne(entryList.FloatingEntries);
                }
            } while (--newLastIndex > index);
            return indexEntry;
        }
public IndexDirectoryEntry Insert ( int index , IndexDirectoryEntryMode mode ) { var entryListsCount = virtualizableLength ; if ( index >= entryListsCount ) { return Add ( index , mode ) ; } var newLastIndex = entryListsCount ; var indexEntry = new IndexDirectoryEntry ( index , mode ) ; entriesList . Insert ( index , new Entries ( new List < IndexDirectoryEntry > ( ) { indexEntry } ) ) ; virtualizableLength ++ ; do { var entryList = entriesList [ newLastIndex ] ; if ( ! ( entryList is null ) ) { static void increaseEntryIndexesByOne ( List < IndexDirectoryEntry > entries ) { var entriesCount = entries . Count ; for ( var entryIndex = 0 ; entryIndex < entriesCount ; entryIndex ++ ) { entries [ entryIndex ] . Index ++ ; } } increaseEntryIndexesByOne ( entryList . NormalEntries ) ; increaseEntryIndexesByOne ( entryList . FloatingEntries ) ; } } while ( -- newLastIndex > index ) ; return indexEntry ; }
Inserts  between  - 1
and  and will cause to move existing indexes at
by one.
Inserts between - 1 and and will cause to move existing indexes at by one .
The index entry.
The index entry .
index
int
The to be inserted index.
The to be inserted index .
mode
IndexDirectoryEntryMode
The mode for the index.
The mode for the index .