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
- HwndHost.cs
- XmlName.cs
- Metadata.cs
- DSACryptoServiceProvider.cs
- StrongName.cs
- BufferedGraphicsContext.cs
- linebase.cs
- adornercollection.cs
- ScriptControlDescriptor.cs
- Timeline.cs
- SignatureToken.cs
- AvtEvent.cs
- CollectionType.cs
- TextWriterEngine.cs
- IDataContractSurrogate.cs
- Stylesheet.cs
- ProfileGroupSettingsCollection.cs
- ResourceContainer.cs
- MediaCommands.cs
- SizeAnimation.cs
- BitSet.cs
- QueueProcessor.cs
- ErrorHandlingAcceptor.cs
- ProcessRequestArgs.cs
- ToolboxComponentsCreatingEventArgs.cs
- _BufferOffsetSize.cs
- ConstraintConverter.cs
- _ProxyRegBlob.cs
- DataGridCellInfo.cs
- ConfigXmlElement.cs
- QueryCoreOp.cs
- DateTimeHelper.cs
- RecordManager.cs
- UIEndRequest.cs
- SetterBaseCollection.cs
- ToolStripCustomTypeDescriptor.cs
- CodeEntryPointMethod.cs
- SchemeSettingElementCollection.cs
- DynamicDataManager.cs
- ListParaClient.cs
- OracleConnection.cs
- SurrogateSelector.cs
- DeviceContexts.cs
- AppendHelper.cs
- DWriteFactory.cs
- arabicshape.cs
- GAC.cs
- TextParagraph.cs
- TreeViewItemAutomationPeer.cs
- SqlConnectionManager.cs
- XmlSchemaObject.cs
- RemoteWebConfigurationHost.cs
- Cell.cs
- CallbackHandler.cs
- StringToken.cs
- XmlSchemaExporter.cs
- ColumnTypeConverter.cs
- BaseCAMarshaler.cs
- SynchronizedDispatch.cs
- ScopedKnownTypes.cs
- UrlAuthorizationModule.cs
- PointF.cs
- AssemblyLoader.cs
- StreamHelper.cs
- FacetValues.cs
- BinaryReader.cs
- CookieHandler.cs
- EditorZone.cs
- ChameleonKey.cs
- TabControl.cs
- nulltextnavigator.cs
- IMembershipProvider.cs
- CryptoApi.cs
- QueryAccessibilityHelpEvent.cs
- UdpSocket.cs
- MethodSignatureGenerator.cs
- DefaultIfEmptyQueryOperator.cs
- DrawListViewItemEventArgs.cs
- TextStore.cs
- SingleAnimationUsingKeyFrames.cs
- ClientWindowsAuthenticationMembershipProvider.cs
- TextDecorationCollection.cs
- _HeaderInfo.cs
- FixedTextSelectionProcessor.cs
- HtmlTableRowCollection.cs
- AssemblyContextControlItem.cs
- XsdBuildProvider.cs
- Lease.cs
- EventDescriptorCollection.cs
- SortedList.cs
- GlyphingCache.cs
- ZipIOExtraFieldZip64Element.cs
- AutoScrollExpandMessageFilter.cs
- MetadataArtifactLoaderResource.cs
- Floater.cs
- SuppressMessageAttribute.cs
- Expression.cs
- BevelBitmapEffect.cs
- DelegatedStream.cs
- Pen.cs