Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / Parallel / QueryOperators / Inlined / InlinedAggregationOperatorEnumerator.cs / 1305376 / InlinedAggregationOperatorEnumerator.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // InlinedAggregationOperatorEnumerator.cs // //[....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Threading; namespace System.Linq.Parallel { //---------------------------------------------------------------------------------------- // Inlined aggregate operators for finding the min/max values for primitives (int, long, float, // double, decimal). Versions are also offered for the nullable primitives (int?, long?, float?, // double?, decimal?), which differ slightly in behavior: they return a null value for empty // streams, whereas the ordinary primitive versions throw. // //--------------------------------------------------------------------------------------- // Inlined average operators for primitives (int, long, float, double, decimal), and the // nullable variants. The difference between the nromal and nullable variety is that // nulls are skipped in tallying the count and sum for the average. // ////// A class with some shared implementation between all aggregation enumerators. /// ///internal abstract class InlinedAggregationOperatorEnumerator : QueryOperatorEnumerator { private int m_partitionIndex; // This partition's unique index. protected CancellationToken m_cancellationToken; //--------------------------------------------------------------------------------------- // Instantiates a new aggregation operator. // internal InlinedAggregationOperatorEnumerator(int partitionIndex, CancellationToken cancellationToken) { m_partitionIndex = partitionIndex; m_cancellationToken = cancellationToken; } //--------------------------------------------------------------------------------------- // Tallies up the sum of the underlying data source, walking the entire thing the first // time MoveNext is called on this object. There is a boilerplate variant used by callers, // and then one that is used for extensibility by subclasses. // internal sealed override bool MoveNext(ref TIntermediate currentElement, ref int currentKey) { if (MoveNextCore(ref currentElement)) { // A reduction's "index" is the same as its partition number. currentKey = m_partitionIndex; return true; } return false; } protected abstract bool MoveNextCore(ref TIntermediate currentElement); } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // InlinedAggregationOperatorEnumerator.cs // // [....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Threading; namespace System.Linq.Parallel { //---------------------------------------------------------------------------------------- // Inlined aggregate operators for finding the min/max values for primitives (int, long, float, // double, decimal). Versions are also offered for the nullable primitives (int?, long?, float?, // double?, decimal?), which differ slightly in behavior: they return a null value for empty // streams, whereas the ordinary primitive versions throw. // //--------------------------------------------------------------------------------------- // Inlined average operators for primitives (int, long, float, double, decimal), and the // nullable variants. The difference between the nromal and nullable variety is that // nulls are skipped in tallying the count and sum for the average. // ////// A class with some shared implementation between all aggregation enumerators. /// ///internal abstract class InlinedAggregationOperatorEnumerator : QueryOperatorEnumerator { private int m_partitionIndex; // This partition's unique index. protected CancellationToken m_cancellationToken; //--------------------------------------------------------------------------------------- // Instantiates a new aggregation operator. // internal InlinedAggregationOperatorEnumerator(int partitionIndex, CancellationToken cancellationToken) { m_partitionIndex = partitionIndex; m_cancellationToken = cancellationToken; } //--------------------------------------------------------------------------------------- // Tallies up the sum of the underlying data source, walking the entire thing the first // time MoveNext is called on this object. There is a boilerplate variant used by callers, // and then one that is used for extensibility by subclasses. // internal sealed override bool MoveNext(ref TIntermediate currentElement, ref int currentKey) { if (MoveNextCore(ref currentElement)) { // A reduction's "index" is the same as its partition number. currentKey = m_partitionIndex; return true; } return false; } protected abstract bool MoveNextCore(ref TIntermediate currentElement); } } // 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
- ModuleConfigurationInfo.cs
- GroupLabel.cs
- ServiceChannelManager.cs
- MissingSatelliteAssemblyException.cs
- XmlSchemaSequence.cs
- DrawingAttributes.cs
- KeyValuePair.cs
- SqlTrackingQuery.cs
- BaseDataList.cs
- ControlParameter.cs
- ShaderRenderModeValidation.cs
- UInt16.cs
- Menu.cs
- OutputCacheSettings.cs
- remotingproxy.cs
- FormConverter.cs
- ConfigurationLockCollection.cs
- smtpconnection.cs
- PointIndependentAnimationStorage.cs
- MethodCallTranslator.cs
- CryptoConfig.cs
- AxisAngleRotation3D.cs
- InterleavedZipPartStream.cs
- KeyValueConfigurationElement.cs
- XsdBuilder.cs
- Canvas.cs
- VectorAnimationUsingKeyFrames.cs
- SelectionItemPattern.cs
- RtfControls.cs
- CodeMemberField.cs
- DataKey.cs
- HiddenField.cs
- MenuItemBindingCollection.cs
- MsmqEncryptionAlgorithm.cs
- EntityKeyElement.cs
- SudsWriter.cs
- CommonDialog.cs
- ArrayHelper.cs
- COM2PictureConverter.cs
- NamespaceQuery.cs
- ResourcePermissionBaseEntry.cs
- CodeDOMProvider.cs
- HttpServerChannel.cs
- DictionaryContent.cs
- ChannelServices.cs
- CorePropertiesFilter.cs
- ProtectedConfigurationSection.cs
- SessionStateSection.cs
- GcSettings.cs
- SystemWebCachingSectionGroup.cs
- NameValueFileSectionHandler.cs
- ErrorFormatter.cs
- RuleRef.cs
- MenuItemBinding.cs
- EdmSchemaAttribute.cs
- ByteAnimation.cs
- CodeLinePragma.cs
- ProtectedConfiguration.cs
- UseAttributeSetsAction.cs
- CorruptingExceptionCommon.cs
- UnmanagedMarshal.cs
- ContextMenuService.cs
- UiaCoreProviderApi.cs
- NotifyInputEventArgs.cs
- TriggerBase.cs
- BasicCellRelation.cs
- TraceSource.cs
- OleDbParameter.cs
- MatrixKeyFrameCollection.cs
- DoubleLinkListEnumerator.cs
- SHA256Managed.cs
- UIntPtr.cs
- Stopwatch.cs
- ViewStateChangedEventArgs.cs
- ThreadSafeList.cs
- _FtpDataStream.cs
- ConnectionString.cs
- TypeElement.cs
- PnrpPeerResolverBindingElement.cs
- InvokeProviderWrapper.cs
- COM2Properties.cs
- RegexParser.cs
- RepeaterItemEventArgs.cs
- PrincipalPermission.cs
- Composition.cs
- SpAudioStreamWrapper.cs
- DataListItem.cs
- TextDecoration.cs
- CustomAttributeFormatException.cs
- RangeBase.cs
- NameValueFileSectionHandler.cs
- TargetControlTypeAttribute.cs
- MdImport.cs
- URLMembershipCondition.cs
- wgx_render.cs
- NamespaceEmitter.cs
- AQNBuilder.cs
- AutomationPatternInfo.cs
- ImageListImage.cs
- WinFormsComponentEditor.cs