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
- AnnouncementEventArgs.cs
- CorrelationRequestContext.cs
- _BasicClient.cs
- GridViewColumnCollectionChangedEventArgs.cs
- PathFigureCollectionConverter.cs
- PointLightBase.cs
- _SslStream.cs
- PathFigureCollectionValueSerializer.cs
- linebase.cs
- TraceSwitch.cs
- WsatServiceCertificate.cs
- WindowsFormsLinkLabel.cs
- MediaEntryAttribute.cs
- DataViewListener.cs
- Rect3DValueSerializer.cs
- CompilationLock.cs
- PhysicalAddress.cs
- BlurEffect.cs
- WindowsFormsHost.cs
- ExceptionAggregator.cs
- EntityDataSourceDesignerHelper.cs
- SAPICategories.cs
- HMACSHA1.cs
- ElapsedEventArgs.cs
- SystemNetworkInterface.cs
- UserControlAutomationPeer.cs
- HotSpotCollectionEditor.cs
- ClusterSafeNativeMethods.cs
- XamlSerializer.cs
- GroupQuery.cs
- DocumentXmlWriter.cs
- TransformerInfo.cs
- XmlILConstructAnalyzer.cs
- StylusDevice.cs
- WebPartConnectionsConfigureVerb.cs
- AudioDeviceOut.cs
- CodeArrayIndexerExpression.cs
- FormattedTextSymbols.cs
- FullTextLine.cs
- SrgsElementFactory.cs
- SubtreeProcessor.cs
- WinInetCache.cs
- CodeSnippetExpression.cs
- Stack.cs
- StaticResourceExtension.cs
- TypeBuilderInstantiation.cs
- KnownBoxes.cs
- ComEventsInfo.cs
- InternalConfigConfigurationFactory.cs
- XmlAttributeOverrides.cs
- EmptyReadOnlyDictionaryInternal.cs
- PerfCounterSection.cs
- CompoundFileIOPermission.cs
- ObjectItemCollection.cs
- RotateTransform.cs
- OracleBoolean.cs
- wmiprovider.cs
- AppModelKnownContentFactory.cs
- FontFamilyIdentifier.cs
- HttpAsyncResult.cs
- Line.cs
- AddInActivator.cs
- ScrollBar.cs
- DataSourceCache.cs
- webeventbuffer.cs
- Source.cs
- ReferenceConverter.cs
- SweepDirectionValidation.cs
- DbConnectionInternal.cs
- StringFunctions.cs
- Geometry3D.cs
- FormatterConverter.cs
- HttpCapabilitiesBase.cs
- MSAAEventDispatcher.cs
- EmbeddedMailObjectCollectionEditor.cs
- Animatable.cs
- Binding.cs
- XmlElementAttribute.cs
- Control.cs
- WeakReferenceEnumerator.cs
- VisualTransition.cs
- PolyBezierSegment.cs
- WindowsAuthenticationModule.cs
- Underline.cs
- IDictionary.cs
- ToolBarButton.cs
- CursorInteropHelper.cs
- altserialization.cs
- FontUnitConverter.cs
- Error.cs
- XmlSchemaDocumentation.cs
- NavigationPropertyEmitter.cs
- VerificationAttribute.cs
- TextCharacters.cs
- CreateInstanceBinder.cs
- MessageDecoder.cs
- StringWriter.cs
- IgnoreDeviceFilterElementCollection.cs
- XmlChildNodes.cs
- FileSystemEventArgs.cs