Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / System / Linq / Parallel / Enumerables / EmptyEnumerable.cs / 1305376 / EmptyEnumerable.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // EmptyEnumerable.cs // //[....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections; using System.Collections.Generic; namespace System.Linq.Parallel { ////// We occ----ionally need a no-op enumerator to stand-in when we don't have data left /// within a partition's data stream. These are simple enumerable and enumerator /// implementations that always and consistently yield no elements. /// ///internal class EmptyEnumerable : ParallelQuery { private EmptyEnumerable() : base(QuerySettings.Empty) { } // A singleton cached and shared among callers. private static EmptyEnumerable s_instance; private static EmptyEnumerator s_enumeratorInstance; internal static EmptyEnumerable Instance { get { if (s_instance == null) { // There is no need for thread safety here. s_instance = new EmptyEnumerable (); } return s_instance; } } public override IEnumerator GetEnumerator() { if (s_enumeratorInstance == null) { // There is no need for thread safety here. s_enumeratorInstance = new EmptyEnumerator (); } return s_enumeratorInstance; } } internal class EmptyEnumerator : QueryOperatorEnumerator , IEnumerator { internal override bool MoveNext(ref T currentElement, ref int currentKey) { return false; } // IEnumerator methods. public T Current { get { return default(T); } } object IEnumerator.Current { get { return null; } } public bool MoveNext() { return false; } void Collections.IEnumerator.Reset() { } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ // // EmptyEnumerable.cs // // [....] // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Collections; using System.Collections.Generic; namespace System.Linq.Parallel { ////// We occ----ionally need a no-op enumerator to stand-in when we don't have data left /// within a partition's data stream. These are simple enumerable and enumerator /// implementations that always and consistently yield no elements. /// ///internal class EmptyEnumerable : ParallelQuery { private EmptyEnumerable() : base(QuerySettings.Empty) { } // A singleton cached and shared among callers. private static EmptyEnumerable s_instance; private static EmptyEnumerator s_enumeratorInstance; internal static EmptyEnumerable Instance { get { if (s_instance == null) { // There is no need for thread safety here. s_instance = new EmptyEnumerable (); } return s_instance; } } public override IEnumerator GetEnumerator() { if (s_enumeratorInstance == null) { // There is no need for thread safety here. s_enumeratorInstance = new EmptyEnumerator (); } return s_enumeratorInstance; } } internal class EmptyEnumerator : QueryOperatorEnumerator , IEnumerator { internal override bool MoveNext(ref T currentElement, ref int currentKey) { return false; } // IEnumerator methods. public T Current { get { return default(T); } } object IEnumerator.Current { get { return null; } } public bool MoveNext() { return false; } void Collections.IEnumerator.Reset() { } } } // 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
- InternalBufferOverflowException.cs
- DesignerTransactionCloseEvent.cs
- VectorCollectionConverter.cs
- ManipulationVelocities.cs
- XLinq.cs
- NativeCppClassAttribute.cs
- ValidateNames.cs
- x509store.cs
- XmlUrlEditor.cs
- Site.cs
- DeviceFilterDictionary.cs
- SHA384Cng.cs
- InputLangChangeEvent.cs
- tooltip.cs
- WbemProvider.cs
- ContentPosition.cs
- SqlVisitor.cs
- XPathDocumentBuilder.cs
- ClassGenerator.cs
- WebScriptMetadataFormatter.cs
- DoWorkEventArgs.cs
- SapiRecoInterop.cs
- AsymmetricKeyExchangeDeformatter.cs
- SerializationBinder.cs
- SqlDuplicator.cs
- EntityDataSourceSelectingEventArgs.cs
- TabPage.cs
- GrowingArray.cs
- WindowsTooltip.cs
- Rectangle.cs
- ObjectCacheHost.cs
- WmlMobileTextWriter.cs
- SQLChars.cs
- ImmutableObjectAttribute.cs
- CommonObjectSecurity.cs
- BindingExpression.cs
- MeasureItemEvent.cs
- TagMapInfo.cs
- EventManager.cs
- CaseInsensitiveOrdinalStringComparer.cs
- RelatedImageListAttribute.cs
- GridViewSelectEventArgs.cs
- SoapInteropTypes.cs
- DiagnosticsConfigurationHandler.cs
- SHA1.cs
- _NegotiateClient.cs
- TextRangeEditLists.cs
- TreePrinter.cs
- ProfileSettings.cs
- AttributeTableBuilder.cs
- SelectionHighlightInfo.cs
- CompatibleComparer.cs
- SimpleApplicationHost.cs
- CompareInfo.cs
- SimpleWebHandlerParser.cs
- LogRecordSequence.cs
- HttpEncoder.cs
- IODescriptionAttribute.cs
- ManualResetEvent.cs
- ModelVisual3D.cs
- WebBrowserHelper.cs
- LoadedOrUnloadedOperation.cs
- TreeNodeSelectionProcessor.cs
- BaseResourcesBuildProvider.cs
- ReadOnlyObservableCollection.cs
- QuaternionRotation3D.cs
- SkewTransform.cs
- WebException.cs
- ComponentDispatcherThread.cs
- Menu.cs
- InstancePersistence.cs
- ObjectListCommandEventArgs.cs
- AsymmetricKeyExchangeFormatter.cs
- EntityContainerAssociationSet.cs
- FileEnumerator.cs
- RuntimeConfig.cs
- HtmlTableCellCollection.cs
- RequestQueue.cs
- Transform3D.cs
- PublisherMembershipCondition.cs
- VisualStyleRenderer.cs
- AttributeConverter.cs
- ApplicationCommands.cs
- ContentPosition.cs
- QilLiteral.cs
- SerializableAttribute.cs
- BackgroundFormatInfo.cs
- CodeAttributeArgumentCollection.cs
- ShortcutKeysEditor.cs
- xdrvalidator.cs
- XmlDocumentSerializer.cs
- FixedTextView.cs
- StyleCollection.cs
- PrintDialogException.cs
- FlowLayout.cs
- Tracer.cs
- SmtpAuthenticationManager.cs
- Win32KeyboardDevice.cs
- UpdateCommand.cs
- ObjectQuery_EntitySqlExtensions.cs