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
- ZoomPercentageConverter.cs
- Timer.cs
- CriticalHandle.cs
- Fault.cs
- ToolStripHighContrastRenderer.cs
- ObjectParameter.cs
- DataGridViewCellStateChangedEventArgs.cs
- Walker.cs
- AcceptorSessionSymmetricTransportSecurityProtocol.cs
- StylusPlugin.cs
- ScrollChrome.cs
- BuildManagerHost.cs
- NameHandler.cs
- ConfigDefinitionUpdates.cs
- SendSecurityHeaderElementContainer.cs
- DataList.cs
- CompilerErrorCollection.cs
- WaitForChangedResult.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- RegistryDataKey.cs
- ErrorHandlingAcceptor.cs
- CodeBinaryOperatorExpression.cs
- SerializableTypeCodeDomSerializer.cs
- DataObject.cs
- HwndMouseInputProvider.cs
- SByteStorage.cs
- SafePointer.cs
- ObjectCacheSettings.cs
- GeometryHitTestResult.cs
- CreateUserWizard.cs
- FloaterParaClient.cs
- FlowLayoutPanel.cs
- AsyncInvokeContext.cs
- EndPoint.cs
- GroupBoxRenderer.cs
- ToolStripGrip.cs
- DataKeyArray.cs
- Gdiplus.cs
- ZipIORawDataFileBlock.cs
- MSG.cs
- FormattedText.cs
- HostedTcpTransportManager.cs
- EntityConnection.cs
- InstanceNormalEvent.cs
- OrderedDictionary.cs
- SmiEventSink.cs
- BCLDebug.cs
- XmlSiteMapProvider.cs
- WmlTextViewAdapter.cs
- RequestDescription.cs
- TdsRecordBufferSetter.cs
- RunWorkerCompletedEventArgs.cs
- ItemsPresenter.cs
- TrackingWorkflowEventArgs.cs
- AspNetSynchronizationContext.cs
- PipeStream.cs
- ProfileInfo.cs
- DataRowComparer.cs
- ProxyAttribute.cs
- StylusPointCollection.cs
- RijndaelManaged.cs
- WindowsAltTab.cs
- ACE.cs
- ViewBox.cs
- ModifierKeysConverter.cs
- ReachDocumentSequenceSerializer.cs
- QuaternionAnimation.cs
- OutOfProcStateClientManager.cs
- MachineKeySection.cs
- PerformanceCounterCategory.cs
- DetailsViewAutoFormat.cs
- EdmFunction.cs
- AlphaSortedEnumConverter.cs
- NumericPagerField.cs
- Content.cs
- XmlSchemaComplexType.cs
- XmlSchemaSimpleTypeRestriction.cs
- InputChannel.cs
- SqlResolver.cs
- Variant.cs
- Formatter.cs
- BaseInfoTable.cs
- Part.cs
- HtmlWindowCollection.cs
- _NestedMultipleAsyncResult.cs
- SmtpSection.cs
- DeriveBytes.cs
- InvalidateEvent.cs
- ContentPosition.cs
- ContainerParagraph.cs
- cache.cs
- LinqDataSourceUpdateEventArgs.cs
- LinkLabelLinkClickedEvent.cs
- NotifyInputEventArgs.cs
- Claim.cs
- FixedSOMLineCollection.cs
- AncestorChangedEventArgs.cs
- GiveFeedbackEventArgs.cs
- ExpressionReplacer.cs
- CFStream.cs