Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / Parallel / Utils / GrowingArray.cs / 1305376 / GrowingArray.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // GrowingArray.cs // //[....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Diagnostics.Contracts; namespace System.Linq.Parallel { ////// A growing array. Unlike List{T}, it makes the internal array available to its user. /// ///internal class GrowingArray { T[] m_array; int m_count; const int DEFAULT_ARRAY_SIZE = 1024; internal GrowingArray() { m_array = new T[DEFAULT_ARRAY_SIZE]; m_count = 0; } //---------------------------------------------------------------------------------------- // Returns the internal array representing the list. Note that the array may be larger // than necessary to hold all elements in the list. // internal T[] InternalArray { get { return m_array; } } internal int Count { get { return m_count; } } internal void Add(T element) { if (m_count >= m_array.Length) { GrowArray(2 * m_array.Length); } m_array[m_count++] = element; } private void GrowArray(int newSize) { Contract.Assert(newSize > m_array.Length); T[] array2 = new T[newSize]; m_array.CopyTo(array2, 0); m_array = array2; } internal void CopyFrom(T[] otherArray, int otherCount) { // Ensure there is just enough room for both. if (m_count + otherCount > m_array.Length) { GrowArray(m_count + otherCount); } // And now just blit the keys directly. Array.Copy(otherArray, 0, m_array, m_count, otherCount); m_count += otherCount; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TcpProcessProtocolHandler.cs
- GridItemCollection.cs
- WpfMemberInvoker.cs
- ProcessModelSection.cs
- ConnectionPool.cs
- Misc.cs
- TailCallAnalyzer.cs
- XmlTypeMapping.cs
- WebPartChrome.cs
- ResourceProperty.cs
- FileLevelControlBuilderAttribute.cs
- CodeIdentifier.cs
- Message.cs
- SoapProcessingBehavior.cs
- DockPanel.cs
- QilReplaceVisitor.cs
- ModelServiceImpl.cs
- ObjectTag.cs
- PermissionSetEnumerator.cs
- ListControl.cs
- PolicyException.cs
- XmlCompatibilityReader.cs
- MobileDeviceCapabilitiesSectionHandler.cs
- WinFormsComponentEditor.cs
- DataGridViewRowStateChangedEventArgs.cs
- MasterPageCodeDomTreeGenerator.cs
- DesignerProperties.cs
- JapaneseCalendar.cs
- ErrorHandlingReceiver.cs
- SafeCryptoHandles.cs
- SemanticKeyElement.cs
- DataControlLinkButton.cs
- SelectionItemProviderWrapper.cs
- Operand.cs
- ButtonRenderer.cs
- ConstrainedDataObject.cs
- SecondaryIndex.cs
- Html32TextWriter.cs
- ListViewItem.cs
- HandlerFactoryWrapper.cs
- TimelineGroup.cs
- Message.cs
- Environment.cs
- ApplicationSecurityInfo.cs
- baseshape.cs
- NameValueCache.cs
- ActivityExecutor.cs
- JobInputBins.cs
- COAUTHIDENTITY.cs
- ResumeStoryboard.cs
- DataKeyCollection.cs
- DataGridViewLayoutData.cs
- SplitterPanel.cs
- FunctionDetailsReader.cs
- XslVisitor.cs
- TraceListener.cs
- Page.cs
- GuidConverter.cs
- DataGridViewButtonColumn.cs
- InlineObject.cs
- FlowLayoutPanelDesigner.cs
- XPathConvert.cs
- WebPartZoneDesigner.cs
- DESCryptoServiceProvider.cs
- LinearQuaternionKeyFrame.cs
- DataGridViewElement.cs
- TagMapCollection.cs
- ComboBox.cs
- DataKeyCollection.cs
- AppDomainAttributes.cs
- TreeView.cs
- StatusBarDrawItemEvent.cs
- SelectionGlyphBase.cs
- UrlMappingCollection.cs
- GridViewColumnCollection.cs
- SoapTypeAttribute.cs
- sqlinternaltransaction.cs
- DispatcherTimer.cs
- CellTreeSimplifier.cs
- Interfaces.cs
- SQLDateTime.cs
- CharacterMetricsDictionary.cs
- ChannelOptions.cs
- LinqDataSourceView.cs
- CodeLinePragma.cs
- SuppressedPackageProperties.cs
- StandardRuntimeEnumValidatorAttribute.cs
- LifetimeManager.cs
- ClientBuildManager.cs
- ComPlusInstanceContextInitializer.cs
- CharEntityEncoderFallback.cs
- DataGridViewCellFormattingEventArgs.cs
- ScrollBarAutomationPeer.cs
- Matrix3D.cs
- TimeSpanConverter.cs
- ModelPropertyDescriptor.cs
- DecimalKeyFrameCollection.cs
- Helpers.cs
- ServiceOperation.cs
- ComponentResourceManager.cs