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
- StringConverter.cs
- AuthenticodeSignatureInformation.cs
- DataRowChangeEvent.cs
- SystemIPAddressInformation.cs
- DataObjectAttribute.cs
- Double.cs
- DisableDpiAwarenessAttribute.cs
- TreeNodeSelectionProcessor.cs
- Int32KeyFrameCollection.cs
- XmlTextReader.cs
- XPathException.cs
- FixedTextPointer.cs
- KeyboardEventArgs.cs
- InputScopeNameConverter.cs
- DataGridSortCommandEventArgs.cs
- AsyncDataRequest.cs
- TriState.cs
- MethodExpr.cs
- HttpResponseHeader.cs
- UserControlBuildProvider.cs
- JoinElimination.cs
- OracleDateTime.cs
- PerfProviderCollection.cs
- util.cs
- FileStream.cs
- ActiveDocumentEvent.cs
- BitmapCodecInfo.cs
- Model3DCollection.cs
- CaseInsensitiveComparer.cs
- DBConnectionString.cs
- TypeUtil.cs
- Win32PrintDialog.cs
- DocumentPageHost.cs
- GridViewCommandEventArgs.cs
- BooleanToVisibilityConverter.cs
- KnownAssembliesSet.cs
- BitmapCodecInfo.cs
- EventProviderClassic.cs
- EdmItemError.cs
- AnnotationComponentChooser.cs
- LassoHelper.cs
- SchemaSetCompiler.cs
- NetworkInterface.cs
- ConfigurationFileMap.cs
- SystemIPv4InterfaceProperties.cs
- RawMouseInputReport.cs
- Border.cs
- TableCellCollection.cs
- SystemFonts.cs
- StyleModeStack.cs
- UInt16.cs
- SqlDataSourceConnectionPanel.cs
- TextAdaptor.cs
- WinFormsSpinner.cs
- RadioButtonPopupAdapter.cs
- uribuilder.cs
- KnownBoxes.cs
- MultilineStringConverter.cs
- SecurityVerifiedMessage.cs
- WindowsImpersonationContext.cs
- Color.cs
- StorageInfo.cs
- Certificate.cs
- ReachPageContentSerializerAsync.cs
- FixUp.cs
- DnsPermission.cs
- EventManager.cs
- DoubleCollection.cs
- SqlAggregateChecker.cs
- ExtendedPropertyCollection.cs
- HttpConfigurationSystem.cs
- OleDbFactory.cs
- TypeCodeDomSerializer.cs
- AxisAngleRotation3D.cs
- ActivityExecutorDelegateInfo.cs
- TextBox.cs
- Wizard.cs
- SrgsDocument.cs
- SystemUnicastIPAddressInformation.cs
- FamilyCollection.cs
- TcpServerChannel.cs
- XmlQueryCardinality.cs
- DataMemberFieldConverter.cs
- CultureInfoConverter.cs
- WebPartChrome.cs
- MultiBindingExpression.cs
- CngProvider.cs
- HScrollBar.cs
- WebPartEditorCancelVerb.cs
- DisplayNameAttribute.cs
- ScaleTransform3D.cs
- PartManifestEntry.cs
- Compensate.cs
- CodeConstructor.cs
- DbConnectionPoolGroup.cs
- ObjectTokenCategory.cs
- HandleCollector.cs
- CheckedPointers.cs
- Transform3DGroup.cs
- DataGridrowEditEndingEventArgs.cs