Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Xml / System / Xml / ByteStack.cs / 1305376 / ByteStack.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System; namespace System.Xml { // This stack is designed to minimize object creation for the // objects being stored in the stack by allowing them to be // re-used over time. It basically pushes the objects creating // a high water mark then as Pop() is called they are not removed // so that next time Push() is called it simply returns the last // object that was already on the stack. internal class ByteStack { private byte[] stack; private int growthRate; private int top; private int size; public ByteStack(int growthRate) { this.growthRate = growthRate; top = 0; stack = new byte[growthRate]; size = growthRate; } public void Push(byte data) { if (size == top) { byte[] newstack = new byte[size + growthRate]; if (top > 0) { Buffer.BlockCopy(stack, 0, newstack, 0, top); } stack = newstack; size += growthRate; } stack[top++] = data; } public byte Pop() { if (top > 0) { return stack[--top]; } else { return 0; } } public byte Peek() { if (top > 0) { return stack[top - 1]; } else { return 0; } } public int Length { get { return top; } } } } // 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
- SimpleFieldTemplateFactory.cs
- DbProviderFactoriesConfigurationHandler.cs
- Baml2006ReaderContext.cs
- SqlColumnizer.cs
- StickyNote.cs
- ProvidePropertyAttribute.cs
- Frame.cs
- FixedSOMElement.cs
- DataObjectMethodAttribute.cs
- ApplicationCommands.cs
- ObjectDesignerDataSourceView.cs
- TextMessageEncodingBindingElement.cs
- RawStylusInputReport.cs
- ColorAnimationUsingKeyFrames.cs
- _SslState.cs
- DataGrid.cs
- XmlConvert.cs
- BrowserCapabilitiesFactory.cs
- FieldNameLookup.cs
- TypedReference.cs
- ReachPageContentSerializerAsync.cs
- AutomationPatternInfo.cs
- _StreamFramer.cs
- EDesignUtil.cs
- SoapElementAttribute.cs
- UnsafeNativeMethods.cs
- ErrorWebPart.cs
- SiteMapPath.cs
- HasCopySemanticsAttribute.cs
- MouseActionValueSerializer.cs
- RegisteredDisposeScript.cs
- UIHelper.cs
- PointConverter.cs
- HyperLinkDesigner.cs
- Operand.cs
- ReadOnlyState.cs
- WebConfigurationHost.cs
- RelativeSource.cs
- DecoratedNameAttribute.cs
- QueryStringConverter.cs
- ServiceHttpHandlerFactory.cs
- RuleSettings.cs
- TreeNodeStyle.cs
- TableCellCollection.cs
- TypefaceMetricsCache.cs
- codemethodreferenceexpression.cs
- TextEncodedRawTextWriter.cs
- XamlGridLengthSerializer.cs
- UpdatableWrapper.cs
- XXXOnTypeBuilderInstantiation.cs
- Processor.cs
- RadioButton.cs
- StrongNameIdentityPermission.cs
- SystemColorTracker.cs
- OletxTransactionFormatter.cs
- BinaryNode.cs
- TimeoutValidationAttribute.cs
- QueryOutputWriterV1.cs
- HtmlWindowCollection.cs
- InvalidPipelineStoreException.cs
- ProviderSettings.cs
- BindStream.cs
- CustomErrorCollection.cs
- Comparer.cs
- CompletionCallbackWrapper.cs
- StylusPlugInCollection.cs
- EncodingNLS.cs
- DocumentViewerAutomationPeer.cs
- ToolboxItemWrapper.cs
- DataControlFieldCell.cs
- RunClient.cs
- SafeLibraryHandle.cs
- PropertyCollection.cs
- SmiContext.cs
- AppDomain.cs
- ContainerActivationHelper.cs
- TypeKeyValue.cs
- OleDbException.cs
- uribuilder.cs
- BitmapImage.cs
- ComplexPropertyEntry.cs
- ISAPIRuntime.cs
- StylusDevice.cs
- StorageTypeMapping.cs
- PartitionResolver.cs
- SspiSafeHandles.cs
- UnauthorizedWebPart.cs
- TypeToStringValueConverter.cs
- ListViewDeletedEventArgs.cs
- LogicalTreeHelper.cs
- StaticExtensionConverter.cs
- ScriptIgnoreAttribute.cs
- SoapMessage.cs
- querybuilder.cs
- ToolStripCodeDomSerializer.cs
- RelationshipType.cs
- ModelTreeManager.cs
- bidPrivateBase.cs
- DefaultPropertyAttribute.cs
- Metadata.cs