Code:
/ DotNET / DotNET / 8.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
- DrawTreeNodeEventArgs.cs
- ListControl.cs
- EditorPart.cs
- SpeakProgressEventArgs.cs
- ServiceDeploymentInfo.cs
- FrameworkRichTextComposition.cs
- PairComparer.cs
- FontCacheLogic.cs
- TokenizerHelper.cs
- WebScriptMetadataMessage.cs
- X509ClientCertificateCredentialsElement.cs
- SizeAnimationUsingKeyFrames.cs
- FilteredDataSetHelper.cs
- SymLanguageVendor.cs
- LinearKeyFrames.cs
- ConnectorEditor.cs
- TextEffectResolver.cs
- ValueOfAction.cs
- GenericEnumConverter.cs
- SecurityIdentifierElement.cs
- AVElementHelper.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- CompilationUtil.cs
- SQLInt64Storage.cs
- WhitespaceRuleLookup.cs
- ColumnResizeUndoUnit.cs
- PassportAuthenticationModule.cs
- AnnotationHelper.cs
- HybridWebProxyFinder.cs
- Vector3DConverter.cs
- FormattedText.cs
- BezierSegment.cs
- LateBoundBitmapDecoder.cs
- DataColumnSelectionConverter.cs
- BreakRecordTable.cs
- EntityProviderServices.cs
- UnsafeNativeMethodsPenimc.cs
- SliderAutomationPeer.cs
- TableRow.cs
- AnnotationService.cs
- ASCIIEncoding.cs
- StatusBarAutomationPeer.cs
- BinHexEncoder.cs
- counter.cs
- BinHexDecoder.cs
- DataGridViewColumnCollection.cs
- LinkClickEvent.cs
- EditableLabelControl.cs
- TypeSystemProvider.cs
- SpellerStatusTable.cs
- BaseCollection.cs
- RichTextBox.cs
- ResourceCategoryAttribute.cs
- XmlIncludeAttribute.cs
- SoapCodeExporter.cs
- compensatingcollection.cs
- RuleCache.cs
- JapaneseCalendar.cs
- SerializerProvider.cs
- TextTreeObjectNode.cs
- HttpHandlerActionCollection.cs
- ConvertBinder.cs
- ContentDefinition.cs
- XslAstAnalyzer.cs
- SecuritySessionSecurityTokenProvider.cs
- ResizeGrip.cs
- UserControlAutomationPeer.cs
- _ScatterGatherBuffers.cs
- TemplateBindingExtension.cs
- ContentElement.cs
- GridViewUpdateEventArgs.cs
- StorageMappingItemCollection.cs
- PTConverter.cs
- Pen.cs
- EncoderExceptionFallback.cs
- Wizard.cs
- UrlParameterWriter.cs
- Calendar.cs
- XmlReaderSettings.cs
- SQLMembershipProvider.cs
- Attachment.cs
- MultiPropertyDescriptorGridEntry.cs
- ContentTextAutomationPeer.cs
- CreateUserErrorEventArgs.cs
- InputLanguageProfileNotifySink.cs
- ControlValuePropertyAttribute.cs
- ProtocolsConfiguration.cs
- FixedSOMPageElement.cs
- StatusBarDrawItemEvent.cs
- SamlConditions.cs
- MsmqBindingFilter.cs
- RecordManager.cs
- EntryWrittenEventArgs.cs
- CompilationSection.cs
- BooleanFunctions.cs
- FontStyle.cs
- XmlWhitespace.cs
- BitmapEffectGroup.cs
- COM2ComponentEditor.cs
- LassoHelper.cs