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
- Vars.cs
- EmbeddedMailObject.cs
- ServiceHttpHandlerFactory.cs
- CapabilitiesUse.cs
- XPathNodeIterator.cs
- BinarySerializer.cs
- BitConverter.cs
- TargetFrameworkUtil.cs
- HttpProcessUtility.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- DataControlExtensions.cs
- InstanceContext.cs
- XmlAttribute.cs
- QueryCacheKey.cs
- PixelFormatConverter.cs
- SourceChangedEventArgs.cs
- AmbientValueAttribute.cs
- StylusCaptureWithinProperty.cs
- WebDisplayNameAttribute.cs
- EventTrigger.cs
- FileLoadException.cs
- Root.cs
- FlowDocument.cs
- StylusSystemGestureEventArgs.cs
- CommentEmitter.cs
- ContextProperty.cs
- ProgressBar.cs
- KeyedCollection.cs
- backend.cs
- XPathNodePointer.cs
- NullableBoolConverter.cs
- QueryContinueDragEventArgs.cs
- StructuredProperty.cs
- InkPresenterAutomationPeer.cs
- OleStrCAMarshaler.cs
- ObjectDataSource.cs
- Encoding.cs
- NavigationExpr.cs
- DataPagerFieldItem.cs
- TraceLog.cs
- CompilerGeneratedAttribute.cs
- NonParentingControl.cs
- WebEventTraceProvider.cs
- SQLBinaryStorage.cs
- StreamGeometry.cs
- ExpressionReplacer.cs
- FormattedText.cs
- FacetDescription.cs
- CompareValidator.cs
- ObjectListCommandEventArgs.cs
- SpecialFolderEnumConverter.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- ActivityValidator.cs
- XmlObjectSerializer.cs
- EntityKey.cs
- TransactionBehavior.cs
- DeobfuscatingStream.cs
- BlurBitmapEffect.cs
- EdmToObjectNamespaceMap.cs
- ResourceType.cs
- ApplicationSettingsBase.cs
- _FtpDataStream.cs
- SafeTimerHandle.cs
- Geometry.cs
- ResourceKey.cs
- PropertyReferenceSerializer.cs
- counter.cs
- PaperSource.cs
- BitmapInitialize.cs
- CharacterString.cs
- StickyNoteContentControl.cs
- CacheDependency.cs
- XmlException.cs
- Thumb.cs
- ConnectionStringSettings.cs
- TypeUnloadedException.cs
- FileUpload.cs
- StyleCollection.cs
- PathStreamGeometryContext.cs
- ServiceBuildProvider.cs
- TextElementEnumerator.cs
- StickyNoteHelper.cs
- CacheForPrimitiveTypes.cs
- ApplicationServiceManager.cs
- EpmSyndicationContentSerializer.cs
- TableDetailsRow.cs
- TableLayoutStyleCollection.cs
- WebServiceReceive.cs
- ReadOnlyHierarchicalDataSourceView.cs
- Blend.cs
- TextParentUndoUnit.cs
- ServicesUtilities.cs
- FormViewDeleteEventArgs.cs
- XmlEntityReference.cs
- ScriptResourceInfo.cs
- TracePayload.cs
- CodeExporter.cs
- EntityDataSourceSelectedEventArgs.cs
- RTLAwareMessageBox.cs
- EncoderFallback.cs