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
- OleDbInfoMessageEvent.cs
- StringStorage.cs
- TextOptions.cs
- _ConnectOverlappedAsyncResult.cs
- CodeGenerator.cs
- __ConsoleStream.cs
- RegexGroup.cs
- UidManager.cs
- OdbcPermission.cs
- IItemProperties.cs
- FactoryGenerator.cs
- XsdBuilder.cs
- DataGridHeaderBorder.cs
- _ListenerResponseStream.cs
- OleStrCAMarshaler.cs
- SQLUtility.cs
- RenderData.cs
- StreamBodyWriter.cs
- DeferredSelectedIndexReference.cs
- SoapFault.cs
- EncryptedXml.cs
- SecurityTokenAttachmentMode.cs
- RegexStringValidator.cs
- DbFunctionCommandTree.cs
- NameValuePair.cs
- EntityProxyFactory.cs
- PermissionRequestEvidence.cs
- SetterBase.cs
- TransformerInfoCollection.cs
- DataProviderNameConverter.cs
- TiffBitmapEncoder.cs
- RootBrowserWindowAutomationPeer.cs
- MailWebEventProvider.cs
- BookmarkNameHelper.cs
- TransactionOptions.cs
- Binding.cs
- TraceRecords.cs
- streamingZipPartStream.cs
- PresentationTraceSources.cs
- ProvidersHelper.cs
- XmlJsonReader.cs
- GridViewUpdatedEventArgs.cs
- RecognitionEventArgs.cs
- loginstatus.cs
- HighlightComponent.cs
- BaseCollection.cs
- PrimitiveSchema.cs
- COM2Enum.cs
- GridViewUpdateEventArgs.cs
- Condition.cs
- RuntimeHelpers.cs
- PopOutPanel.cs
- SHA256.cs
- Item.cs
- DataGridViewLayoutData.cs
- securitycriticaldata.cs
- ListControl.cs
- ApplicationSecurityManager.cs
- ControlType.cs
- XmlSchemaParticle.cs
- WindowsTokenRoleProvider.cs
- LocalValueEnumerator.cs
- RetriableClipboard.cs
- Vector3DAnimationUsingKeyFrames.cs
- TextWriterEngine.cs
- DynamicActivity.cs
- sqlpipe.cs
- regiisutil.cs
- CommandCollectionEditor.cs
- FontUnit.cs
- WebZoneDesigner.cs
- ProcessModelInfo.cs
- Window.cs
- SafeCoTaskMem.cs
- RemotingServices.cs
- StringBuilder.cs
- SafeNativeMethods.cs
- DateTimeOffsetStorage.cs
- TdsParserHelperClasses.cs
- RectangleConverter.cs
- CodeTypeConstructor.cs
- Asn1IntegerConverter.cs
- _ProxyChain.cs
- WindowsIdentity.cs
- ObfuscateAssemblyAttribute.cs
- OpenFileDialog.cs
- Preprocessor.cs
- ImageSourceTypeConverter.cs
- ContainerCodeDomSerializer.cs
- EditingCommands.cs
- EntityDataSourceReferenceGroup.cs
- XmlILConstructAnalyzer.cs
- UnsafeNativeMethods.cs
- RunClient.cs
- PerspectiveCamera.cs
- FormViewPagerRow.cs
- SqlDataSourceCustomCommandPanel.cs
- BlobPersonalizationState.cs
- ContextMenuService.cs
- StateManagedCollection.cs