Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Xml / System / Xml / ByteStack.cs / 1 / 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. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- JapaneseCalendar.cs
- ManagementEventArgs.cs
- TemplateControl.cs
- Schema.cs
- ProfileParameter.cs
- ExceptionHandlers.cs
- XPathNodePointer.cs
- CheckBoxAutomationPeer.cs
- AdornerPresentationContext.cs
- XamlPathDataSerializer.cs
- TagMapCollection.cs
- lengthconverter.cs
- RawUIStateInputReport.cs
- HtmlLink.cs
- WebPartCatalogAddVerb.cs
- SingleKeyFrameCollection.cs
- X509Certificate2Collection.cs
- Vector3D.cs
- RectangleHotSpot.cs
- SQLInt16Storage.cs
- SimpleTypeResolver.cs
- FreezableCollection.cs
- HandleRef.cs
- FillRuleValidation.cs
- CheckBox.cs
- XPathExpr.cs
- PngBitmapDecoder.cs
- InvalidOperationException.cs
- DbMetaDataFactory.cs
- IDReferencePropertyAttribute.cs
- ThrowHelper.cs
- TypeDescriptionProviderAttribute.cs
- OrderedDictionary.cs
- DesignTimeData.cs
- MetadataUtil.cs
- FormsAuthenticationUserCollection.cs
- HttpFileCollectionWrapper.cs
- DirectoryObjectSecurity.cs
- WizardPanel.cs
- InteropBitmapSource.cs
- LateBoundBitmapDecoder.cs
- JsonReaderDelegator.cs
- TypedReference.cs
- VsPropertyGrid.cs
- SchemaImporter.cs
- SessionStateContainer.cs
- GridViewRowEventArgs.cs
- SpellerHighlightLayer.cs
- SqlComparer.cs
- SharedPersonalizationStateInfo.cs
- DocumentPageView.cs
- EdmSchemaAttribute.cs
- PathFigureCollection.cs
- XmlSchemaAttributeGroup.cs
- SessionSwitchEventArgs.cs
- NativeObjectSecurity.cs
- DataGridRowEventArgs.cs
- XmlSchemaComplexContentExtension.cs
- HttpRequestContext.cs
- GeneralTransform.cs
- StrongNamePublicKeyBlob.cs
- SoapFault.cs
- HttpPostedFile.cs
- ModelTreeEnumerator.cs
- SqlGatherConsumedAliases.cs
- Debug.cs
- KeysConverter.cs
- FlowDocumentReader.cs
- TextBoxDesigner.cs
- ProtocolElementCollection.cs
- EventItfInfo.cs
- WhileDesigner.cs
- ToolZone.cs
- FormViewInsertedEventArgs.cs
- WindowsGraphics.cs
- SystemWebExtensionsSectionGroup.cs
- Int16AnimationUsingKeyFrames.cs
- DateRangeEvent.cs
- KeyConverter.cs
- WorkflowViewStateService.cs
- LinqDataSource.cs
- ConfigsHelper.cs
- WindowsListBox.cs
- FormViewModeEventArgs.cs
- XamlSerializationHelper.cs
- ExtensionWindowResizeGrip.cs
- SystemGatewayIPAddressInformation.cs
- FastEncoderWindow.cs
- WebPartManager.cs
- RelativeSource.cs
- NaturalLanguageHyphenator.cs
- ClientConfigurationSystem.cs
- NavigationProgressEventArgs.cs
- DeferredElementTreeState.cs
- ApplicationContext.cs
- AxisAngleRotation3D.cs
- MouseEventArgs.cs
- HtmlEmptyTagControlBuilder.cs
- ISAPIRuntime.cs
- WebServiceParameterData.cs