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
- ProviderSettingsCollection.cs
- MissingManifestResourceException.cs
- PartialTrustValidationBehavior.cs
- AppSecurityManager.cs
- HttpServerVarsCollection.cs
- ToolStrip.cs
- WindowsFormsSectionHandler.cs
- XD.cs
- DocumentViewer.cs
- BaseParagraph.cs
- IIS7WorkerRequest.cs
- UnsafeNativeMethods.cs
- SEHException.cs
- WebPartDisplayMode.cs
- TimerElapsedEvenArgs.cs
- CodeExpressionCollection.cs
- StorageEntityContainerMapping.cs
- UserControlParser.cs
- ValidationErrorEventArgs.cs
- IdentityReference.cs
- CFStream.cs
- SpecialNameAttribute.cs
- ConsumerConnectionPoint.cs
- ManualResetEvent.cs
- DataViewListener.cs
- GroupByExpressionRewriter.cs
- SelfIssuedAuthProofToken.cs
- ReachIDocumentPaginatorSerializerAsync.cs
- TableAutomationPeer.cs
- Char.cs
- MenuCommand.cs
- DataGridViewRowStateChangedEventArgs.cs
- DynamicILGenerator.cs
- TraceListener.cs
- PackageRelationshipCollection.cs
- CustomErrorCollection.cs
- CollectionChange.cs
- SiteMembershipCondition.cs
- List.cs
- Version.cs
- AtomParser.cs
- MailDefinitionBodyFileNameEditor.cs
- HttpChannelFactory.cs
- NameSpaceExtractor.cs
- ResetableIterator.cs
- SelectionRangeConverter.cs
- DelegateSerializationHolder.cs
- EncodingStreamWrapper.cs
- NumberFunctions.cs
- regiisutil.cs
- DefaultTraceListener.cs
- TreeNodeCollection.cs
- LinkClickEvent.cs
- InputProviderSite.cs
- RoleManagerModule.cs
- MergeFilterQuery.cs
- DesignerActionListCollection.cs
- GatewayDefinition.cs
- InternalDispatchObject.cs
- KnownTypesHelper.cs
- SettingsPropertyIsReadOnlyException.cs
- URLAttribute.cs
- MILUtilities.cs
- NetworkCredential.cs
- TemplateGroupCollection.cs
- SQlBooleanStorage.cs
- DeobfuscatingStream.cs
- ConsoleTraceListener.cs
- SynchronizationLockException.cs
- NativeMethods.cs
- TransformConverter.cs
- EncodingNLS.cs
- EdmToObjectNamespaceMap.cs
- securestring.cs
- RegexReplacement.cs
- TransformPattern.cs
- TagPrefixAttribute.cs
- ThreadPool.cs
- MailAddress.cs
- Point.cs
- InvalidPrinterException.cs
- UnicastIPAddressInformationCollection.cs
- Atom10FormatterFactory.cs
- ObjectDataProvider.cs
- DataGridColumn.cs
- Pkcs7Recipient.cs
- DataListAutoFormat.cs
- InputLanguageSource.cs
- OdbcParameter.cs
- LineInfo.cs
- InvokeFunc.cs
- WsdlInspector.cs
- FontStyles.cs
- XPathScanner.cs
- _ConnectStream.cs
- CompressionTransform.cs
- COM2TypeInfoProcessor.cs
- InputGestureCollection.cs
- dtdvalidator.cs
- Message.cs