Expert C# 5.0: with .NET 4.5 Framework by Mohammad Rahman
Author:Mohammad Rahman
Language: eng
Format: epub
Publisher: Apress®
Published: 2012-12-13T16:00:00+00:00
/* Replace _items with the temporary array which currently holding
* existing contents of the _items array and empty items
* for the expanded cells. */
this._items = destinationArray;
}
else
{
/* Otherwise set _items with 0 items as _emptyArray hold 0 items. */
this._items = List<T>._emptyArray;
}
/*.....*/
}
}
Insert Operation in the List<T>
The InsertRange method works a bit differently in comparison to the Add method. The InsertRange method adds a series of items into the List<T>, starting from a given position of the _items array. From Listing 11-4, you can see that the values {22, 33, 77} are inserted by copying the existing items {3} from the numbers into a new location of the numbers. It started copying items from position 3 of the numbers list and continued until the number of items to copy was equal to the size (4) of the numbers (original sequence) list—the number of items to insert (3). It is also important to calculate the new index where the item will be copied over. The position 6 is calculated using the index plus count, where index refers to the start position of the copy from the source array (provided as input to the InsertRange, which is 3), and count refers to the number of items provided in the InsertRange method to be inserted into the original list. As a result, items {3} will be copied into the array position 6, but the capacity of the original list numbers is four. So it needs to expand the capacity to accommodate more items. After the expansion of the original list, the cell at position {3,4,5} of the expanded original list new values {22,33,77} will be copied. Listing 11-4 shows the usage of the InsertRange method.
Listing 11-4. Example of the InsertRange Method of the List<T> Class
using System;
using System.Collections;
using System.Collections.Generic;
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12570)
Hello! Python by Anthony Briggs(9915)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9796)
The Mikado Method by Ola Ellnestam Daniel Brolund(9778)
Dependency Injection in .NET by Mark Seemann(9339)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8297)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7073)
Microservices with Go by Alexander Shuiskov(6839)
Practical Design Patterns for Java Developers by Miroslav Wengner(6760)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6700)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6413)
Angular Projects - Third Edition by Aristeidis Bampakos(6104)
The Art of Crafting User Stories by The Art of Crafting User Stories(5633)
NetSuite for Consultants - Second Edition by Peter Ries(5567)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5373)
Kotlin in Action by Dmitry Jemerov(5062)
