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
- WebBaseEventKeyComparer.cs
- UIElement3D.cs
- FileSystemEnumerable.cs
- PropertyDescriptorGridEntry.cs
- CharacterMetrics.cs
- Block.cs
- DocumentXPathNavigator.cs
- PathStreamGeometryContext.cs
- FactoryId.cs
- CodeIdentifier.cs
- DistinctQueryOperator.cs
- SystemFonts.cs
- ColorMatrix.cs
- XPathNodeList.cs
- KeyValuePairs.cs
- SpeechUI.cs
- documentsequencetextpointer.cs
- EntityStoreSchemaFilterEntry.cs
- RuntimeConfigurationRecord.cs
- COM2AboutBoxPropertyDescriptor.cs
- MessageCredentialType.cs
- OutputCacheProviderCollection.cs
- SqlCacheDependencySection.cs
- DSASignatureDeformatter.cs
- FixedSOMTextRun.cs
- ListViewInsertionMark.cs
- AsyncContentLoadedEventArgs.cs
- SchemaEntity.cs
- CorrelationKeyCalculator.cs
- OdbcConnectionString.cs
- Int16Animation.cs
- MembershipValidatePasswordEventArgs.cs
- SafeMILHandle.cs
- ApplicationServiceManager.cs
- ComponentEditorForm.cs
- MobileCategoryAttribute.cs
- ManualWorkflowSchedulerService.cs
- WebPartsSection.cs
- safelinkcollection.cs
- ScaleTransform3D.cs
- CrossSiteScriptingValidation.cs
- ToolStripPanelCell.cs
- ErrorFormatter.cs
- HtmlHistory.cs
- ModelUtilities.cs
- PropertyFilterAttribute.cs
- ProtocolsConfigurationEntry.cs
- XPathDescendantIterator.cs
- SelectionEditingBehavior.cs
- RootBrowserWindowAutomationPeer.cs
- ConnectionPoint.cs
- RsaKeyIdentifierClause.cs
- BasicExpandProvider.cs
- FSWPathEditor.cs
- PerformanceCountersElement.cs
- CharacterString.cs
- VectorKeyFrameCollection.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- TypeUnloadedException.cs
- ViewPort3D.cs
- FileDataSourceCache.cs
- DataGridTableCollection.cs
- AssemblyResolver.cs
- FastEncoderWindow.cs
- XmlTextReader.cs
- PriorityItem.cs
- RsaKeyIdentifierClause.cs
- QueryCacheEntry.cs
- AdornerLayer.cs
- ColumnCollection.cs
- mactripleDES.cs
- EntityDataSourceWrapperCollection.cs
- CompoundFileReference.cs
- User.cs
- OutOfMemoryException.cs
- NetworkInformationException.cs
- ellipse.cs
- SoapFault.cs
- ItemAutomationPeer.cs
- PartialTrustVisibleAssemblyCollection.cs
- Rfc2898DeriveBytes.cs
- TextDpi.cs
- AttachedPropertyDescriptor.cs
- TextDecorationCollection.cs
- LambdaReference.cs
- TableLayoutRowStyleCollection.cs
- SchemaEntity.cs
- ThreadStaticAttribute.cs
- NumericUpDownAcceleration.cs
- CodeDirectiveCollection.cs
- InternalCache.cs
- MarshalByRefObject.cs
- XpsViewerException.cs
- InlinedAggregationOperatorEnumerator.cs
- PasswordTextContainer.cs
- MexNamedPipeBindingElement.cs
- Converter.cs
- MouseButton.cs
- VisualState.cs
- ThreadStaticAttribute.cs