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
- FontDifferentiator.cs
- ToolBarOverflowPanel.cs
- SRGSCompiler.cs
- CheckBoxBaseAdapter.cs
- SchemaInfo.cs
- PersonalizationState.cs
- ResetableIterator.cs
- SourceItem.cs
- HostedNamedPipeTransportManager.cs
- InputMethod.cs
- WebBrowserNavigatedEventHandler.cs
- StorageAssociationSetMapping.cs
- ToolStripPanelRenderEventArgs.cs
- InkCanvasAutomationPeer.cs
- LambdaCompiler.Expressions.cs
- HebrewCalendar.cs
- FactoryGenerator.cs
- __TransparentProxy.cs
- Transform.cs
- ManualResetEvent.cs
- XmlSyndicationContent.cs
- ChangeConflicts.cs
- XmlSchemaSequence.cs
- LocalIdKeyIdentifierClause.cs
- ProviderConnectionPointCollection.cs
- WpfGeneratedKnownTypes.cs
- Effect.cs
- PerformanceCounterManager.cs
- SerializationInfo.cs
- AttributeEmitter.cs
- PropertyMappingExceptionEventArgs.cs
- HttpListenerException.cs
- ToolStripSplitButton.cs
- MethodToken.cs
- GroupItemAutomationPeer.cs
- XmlQueryTypeFactory.cs
- Calendar.cs
- DependencyStoreSurrogate.cs
- XmlSchemaComplexContentRestriction.cs
- TextTrailingCharacterEllipsis.cs
- DataStreams.cs
- AssociationTypeEmitter.cs
- PropertyMetadata.cs
- WindowsListViewScroll.cs
- WmpBitmapEncoder.cs
- PageRanges.cs
- COM2ExtendedTypeConverter.cs
- ChangesetResponse.cs
- ClientSideQueueItem.cs
- GroupDescription.cs
- PairComparer.cs
- ObjectRef.cs
- ContentValidator.cs
- ScriptingProfileServiceSection.cs
- FontDifferentiator.cs
- _DigestClient.cs
- RadialGradientBrush.cs
- IndependentAnimationStorage.cs
- FunctionQuery.cs
- MsmqIntegrationProcessProtocolHandler.cs
- TaskHelper.cs
- AppSettingsExpressionBuilder.cs
- ValueChangedEventManager.cs
- TextRenderer.cs
- PackageFilter.cs
- EventLogWatcher.cs
- ProxyWebPartConnectionCollection.cs
- DataControlLinkButton.cs
- ParagraphVisual.cs
- Verify.cs
- Triplet.cs
- CodeMemberMethod.cs
- arc.cs
- DataRowCollection.cs
- HelloOperationCD1AsyncResult.cs
- COM2TypeInfoProcessor.cs
- StringUtil.cs
- XmlDocument.cs
- XmlElementList.cs
- DataGridCaption.cs
- ContextStack.cs
- LineSegment.cs
- ListBoxItemWrapperAutomationPeer.cs
- SByteConverter.cs
- Parameter.cs
- cache.cs
- BitmapSourceSafeMILHandle.cs
- SymbolType.cs
- XmlSignatureProperties.cs
- ACL.cs
- GridLength.cs
- ConfigurationPermission.cs
- IdentityHolder.cs
- ReceiveMessageRecord.cs
- SqlAggregateChecker.cs
- TimeoutHelper.cs
- LineVisual.cs
- PrivateFontCollection.cs
- HtmlUtf8RawTextWriter.cs
- Grant.cs