Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / infocard / Service / managed / Microsoft / InfoCards / FreeIndexList.cs / 1 / FreeIndexList.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.InfoCards { using System; using System.Collections; using System.Collections.Generic; using IDT = Microsoft.InfoCards.Diagnostics.InfoCardTrace; // // Summary: // Manages the list of Free LocalIds in an IndexDataBuffer class // // Remarks: // This is for internal file store use only. // internal class FreeIndexList { Dictionary< Int32, Int32 > m_list; // // Summary: // Creates an instance of FreeIndexList // Parameters: // size: the initial size for the internal Int32 array // public FreeIndexList( int size ) { if( size <= 0 ) { //"value must be > 0" throw IDT.ThrowHelperError( new ArgumentOutOfRangeException( "size", size, SR.GetString( SR.StoreFreeListSizeOutOfRange ) ) ); } m_list = new Dictionary( size ); } // // Summary: // Determins if the specified LocalId is current in the FreeList // // Remarks: // // Parameters: // value: the value of the LocalId to test. // public bool Contains( Int32 value ) { if( value <= 0 ) { //"value must be > 0" throw IDT.ThrowHelperError( new ArgumentOutOfRangeException( "value", value, SR.GetString( SR.StoreFreeListValueOutOfRange ) ) ); } return m_list.ContainsKey( value ); } // // Summary: // Adds a LocalId to the free list // // Remarks: // // Parameters: // value: the value to add to the free list // public void Put( Int32 value ) { if( value <= 0 ) { throw IDT.ThrowHelperError( new ArgumentOutOfRangeException( "value", value, SR.GetString( SR.StoreFreeListValueOutOfRange ) ) ); } m_list.Add( value, value ); } // // Summary: // Get the first free index id available. // // Returns: // The first free item available. // // // Review: A straight hash table would be better here. // public Int32 GetNext() { int next = -1; if( m_list.Count > 0 ) { using( IEnumerator enumerator = m_list.Keys.GetEnumerator() ) { enumerator.MoveNext(); next = enumerator.Current; } m_list.Remove( next ); } return next; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StrongNameUtility.cs
- BaseAsyncResult.cs
- XmlDataSource.cs
- RelatedImageListAttribute.cs
- SqlProcedureAttribute.cs
- EditingCommands.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- StringPropertyBuilder.cs
- AffineTransform3D.cs
- PageVisual.cs
- InstrumentationTracker.cs
- ValidationSummaryDesigner.cs
- XslAstAnalyzer.cs
- SourceFileBuildProvider.cs
- UserControl.cs
- EmptyEnumerable.cs
- DynamicResourceExtensionConverter.cs
- OperatingSystem.cs
- ToolStripPanel.cs
- ControlCachePolicy.cs
- SafeHandles.cs
- InputMethod.cs
- PrintPreviewDialog.cs
- basemetadatamappingvisitor.cs
- NumericUpDown.cs
- ScriptReferenceEventArgs.cs
- RenderDataDrawingContext.cs
- CorrelationManager.cs
- VectorConverter.cs
- Int64AnimationUsingKeyFrames.cs
- UserControlDesigner.cs
- SafeSecurityHandles.cs
- Rect3D.cs
- InstalledVoice.cs
- SessionStateModule.cs
- URI.cs
- EllipseGeometry.cs
- versioninfo.cs
- TextCompositionManager.cs
- ProcessInputEventArgs.cs
- CharacterBufferReference.cs
- AnnotationComponentChooser.cs
- HelpProvider.cs
- FrameAutomationPeer.cs
- HttpTransportSecurityElement.cs
- IssuedTokenClientBehaviorsElementCollection.cs
- UIHelper.cs
- DataServiceQueryOfT.cs
- Rfc2898DeriveBytes.cs
- DBSqlParser.cs
- StreamWriter.cs
- GeometryHitTestResult.cs
- EdmToObjectNamespaceMap.cs
- CacheAxisQuery.cs
- CompositeControl.cs
- XmlToDatasetMap.cs
- ExpressionQuoter.cs
- SqlDataReaderSmi.cs
- OdbcHandle.cs
- Hash.cs
- StrokeSerializer.cs
- followingsibling.cs
- Perspective.cs
- ParagraphVisual.cs
- SizeConverter.cs
- precedingquery.cs
- HandlerFactoryWrapper.cs
- XPathEmptyIterator.cs
- IResourceProvider.cs
- PropertyGeneratedEventArgs.cs
- XmlTypeMapping.cs
- PersonalizationProviderCollection.cs
- CapabilitiesState.cs
- DataGridViewToolTip.cs
- SmiEventSink.cs
- SamlAssertionKeyIdentifierClause.cs
- MimeTypePropertyAttribute.cs
- Utils.cs
- ConfigurationPropertyCollection.cs
- datacache.cs
- Schema.cs
- TextElementEnumerator.cs
- HostedTcpTransportManager.cs
- ObjectDisposedException.cs
- InkCanvasSelection.cs
- DynamicILGenerator.cs
- CompilerErrorCollection.cs
- Misc.cs
- SoapEnumAttribute.cs
- OutputBuffer.cs
- ExpandSegmentCollection.cs
- Type.cs
- SafeReadContext.cs
- WeakReference.cs
- KnowledgeBase.cs
- WinFormsUtils.cs
- Label.cs
- RadioButton.cs
- ToolStripPanelRow.cs
- StandardCommands.cs