Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / Parallel / Utils / ListChunk.cs / 1305376 / ListChunk.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // ListChunk.cs // //[....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections.Generic; using System.Diagnostics.Contracts; namespace System.Linq.Parallel { ////// A linked list of array chunks. Allows direct access to its arrays. /// ///The elements held within. internal class ListChunk: IEnumerable { internal TInputOutput[] m_chunk; private int m_chunkCount; private ListChunk m_nextChunk; private ListChunk m_tailChunk; /// /// Allocates a new root chunk of a particular size. /// internal ListChunk(int size) { Contract.Assert(size > 0); m_chunk = new TInputOutput[size]; m_chunkCount = 0; m_tailChunk = this; } ////// Adds an element to this chunk. Only ever called on the root. /// /// The new element. internal void Add(TInputOutput e) { ListChunktail = m_tailChunk; if (tail.m_chunkCount == tail.m_chunk.Length) { m_tailChunk = new ListChunk (tail.m_chunkCount * 2); tail = (tail.m_nextChunk = m_tailChunk); } tail.m_chunk[tail.m_chunkCount++] = e; } /// /// The next chunk in the linked chain. /// internal ListChunkNext { get { return m_nextChunk; } } /// /// The number of elements contained within this particular chunk. /// internal int Count { get { return m_chunkCount; } } ////// Fetches an enumerator to walk the elements in all chunks rooted from this one. /// public IEnumeratorGetEnumerator() { ListChunk curr = this; while (curr != null) { for (int i = 0; i < curr.m_chunkCount; i++) { yield return curr.m_chunk[i]; } Contract.Assert(curr.m_chunkCount == curr.m_chunk.Length || curr.m_nextChunk == null); curr = curr.m_nextChunk; } } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return ((IEnumerable )this).GetEnumerator(); } } } // 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
- DocumentsTrace.cs
- OracleConnection.cs
- Token.cs
- UnauthorizedWebPart.cs
- PositiveTimeSpanValidator.cs
- FileCodeGroup.cs
- ActivityCodeDomReferenceService.cs
- SpecularMaterial.cs
- TabItemAutomationPeer.cs
- EntityDataSourceWrapperCollection.cs
- SelectionEditor.cs
- NumberAction.cs
- InputLanguageSource.cs
- RepeaterItem.cs
- ToolStripHighContrastRenderer.cs
- ViewBox.cs
- TextFindEngine.cs
- sqlcontext.cs
- BamlLocalizationDictionary.cs
- TreeViewItemAutomationPeer.cs
- WebControlParameterProxy.cs
- RequiredAttributeAttribute.cs
- DataException.cs
- Ref.cs
- SessionStateUtil.cs
- PeerContact.cs
- UriExt.cs
- GenericTextProperties.cs
- QilFactory.cs
- ContourSegment.cs
- PrimaryKeyTypeConverter.cs
- TargetException.cs
- CodeParameterDeclarationExpression.cs
- AstTree.cs
- MutexSecurity.cs
- ListenerPerfCounters.cs
- LogStore.cs
- FixedSchema.cs
- PassportPrincipal.cs
- RegexMatch.cs
- IEnumerable.cs
- CellCreator.cs
- SoapSchemaExporter.cs
- ComponentResourceKey.cs
- LinkLabelLinkClickedEvent.cs
- XhtmlBasicControlAdapter.cs
- TabItem.cs
- CannotUnloadAppDomainException.cs
- CodeEventReferenceExpression.cs
- BatchParser.cs
- UpDownEvent.cs
- WinEventHandler.cs
- SqlTriggerContext.cs
- ContextInformation.cs
- XmlNodeList.cs
- XmlLoader.cs
- XamlReaderHelper.cs
- Binding.cs
- UserPreference.cs
- XsltInput.cs
- PropertyMapper.cs
- WriteFileContext.cs
- XpsDocumentEvent.cs
- MediaContext.cs
- WindowVisualStateTracker.cs
- EdmPropertyAttribute.cs
- WebPartTransformer.cs
- XmlSchemaObjectCollection.cs
- CompareInfo.cs
- SourceFilter.cs
- SQLStringStorage.cs
- StaticFileHandler.cs
- X509CertificateCollection.cs
- PrintPageEvent.cs
- Condition.cs
- MatrixKeyFrameCollection.cs
- TdsEnums.cs
- DiagnosticTraceSource.cs
- BCLDebug.cs
- ValueHandle.cs
- WindowInteractionStateTracker.cs
- TrackPointCollection.cs
- CodeDelegateCreateExpression.cs
- ErrorFormatterPage.cs
- TextContainerChangeEventArgs.cs
- AdCreatedEventArgs.cs
- HtmlTableRowCollection.cs
- ScrollContentPresenter.cs
- BaseDataList.cs
- SmtpLoginAuthenticationModule.cs
- RotateTransform.cs
- X509Certificate2Collection.cs
- XmlDataCollection.cs
- UTF32Encoding.cs
- CryptoProvider.cs
- HwndSourceKeyboardInputSite.cs
- SoapCodeExporter.cs
- QueryPageSettingsEventArgs.cs
- FileUtil.cs
- MergeLocalizationDirectives.cs