Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / untmp / whidbey / QFE / 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
- FactoryGenerator.cs
- TimelineCollection.cs
- ClientUtils.cs
- PlaceHolder.cs
- ListBoxAutomationPeer.cs
- TypeInitializationException.cs
- RelationshipEnd.cs
- InkPresenter.cs
- DefaultTraceListener.cs
- ListViewCancelEventArgs.cs
- FontInfo.cs
- TextSegment.cs
- FaultPropagationQuery.cs
- InfoCardSymmetricAlgorithm.cs
- InputGestureCollection.cs
- Double.cs
- RangeValuePattern.cs
- CryptoKeySecurity.cs
- SymmetricCryptoHandle.cs
- TreeNodeSelectionProcessor.cs
- Int32AnimationUsingKeyFrames.cs
- ParseNumbers.cs
- DataGridViewColumnHeaderCell.cs
- SmtpClient.cs
- DCSafeHandle.cs
- PrinterSettings.cs
- ZipIORawDataFileBlock.cs
- XmlAttributeCache.cs
- XmlILConstructAnalyzer.cs
- TabControlAutomationPeer.cs
- DataViewManagerListItemTypeDescriptor.cs
- OracleConnectionStringBuilder.cs
- ColumnResult.cs
- SingleTagSectionHandler.cs
- EntityDataSourceReferenceGroup.cs
- RotateTransform.cs
- InputBuffer.cs
- EntitySqlQueryBuilder.cs
- TextCompositionManager.cs
- FontFamily.cs
- ExpressionDumper.cs
- CodeLinePragma.cs
- HuffModule.cs
- HostSecurityManager.cs
- TaskFileService.cs
- ApplicationBuildProvider.cs
- X509Chain.cs
- Subtree.cs
- TableProviderWrapper.cs
- StickyNote.cs
- DesignerDataConnection.cs
- CodeMemberField.cs
- UnsafeNativeMethods.cs
- WebRequestModuleElement.cs
- SpellCheck.cs
- SimpleWebHandlerParser.cs
- UndoEngine.cs
- ContentHostHelper.cs
- FeatureSupport.cs
- MarshalDirectiveException.cs
- PointAnimationBase.cs
- PolyQuadraticBezierSegment.cs
- MetadataItem_Static.cs
- ViewDesigner.cs
- OpCodes.cs
- VisualTreeUtils.cs
- MarshalByValueComponent.cs
- ADMembershipProvider.cs
- SafeArrayTypeMismatchException.cs
- BaseWebProxyFinder.cs
- Function.cs
- DataObjectAttribute.cs
- CodeAttributeArgumentCollection.cs
- IDQuery.cs
- DragCompletedEventArgs.cs
- OdbcCommandBuilder.cs
- BreakSafeBase.cs
- Privilege.cs
- ToolStripContentPanel.cs
- followingsibling.cs
- SingleAnimationBase.cs
- NamespaceList.cs
- CorrelationKey.cs
- ConsoleKeyInfo.cs
- StorageAssociationSetMapping.cs
- Action.cs
- ImageMap.cs
- PathGradientBrush.cs
- Selector.cs
- LogSwitch.cs
- ThreadStaticAttribute.cs
- DummyDataSource.cs
- TextDecorationCollection.cs
- ColorConvertedBitmap.cs
- HostedHttpTransportManager.cs
- ObjectConverter.cs
- DataControlFieldCollection.cs
- RuntimeConfig.cs
- XmlHierarchicalEnumerable.cs
- PropertySet.cs