Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Xml / System / Xml / ByteStack.cs / 1305376 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TypeGenericEnumerableViewSchema.cs
- SQLMoneyStorage.cs
- OleDbErrorCollection.cs
- ConfigurationStrings.cs
- path.cs
- PeerNameResolver.cs
- HttpConfigurationContext.cs
- SamlAudienceRestrictionCondition.cs
- GeometryConverter.cs
- CopyNamespacesAction.cs
- ConnectionsZone.cs
- SectionVisual.cs
- Typography.cs
- FontStretchConverter.cs
- EntityViewGenerationAttribute.cs
- FileLogRecord.cs
- ToolStripSplitButton.cs
- PathStreamGeometryContext.cs
- _AutoWebProxyScriptWrapper.cs
- SerializationFieldInfo.cs
- TraceUtility.cs
- BindingElementExtensionElement.cs
- DataGridColumnCollection.cs
- FastEncoder.cs
- OleStrCAMarshaler.cs
- WriteTimeStream.cs
- EventItfInfo.cs
- DefaultProfileManager.cs
- returneventsaver.cs
- Policy.cs
- BaseParser.cs
- TextEffectResolver.cs
- SystemUdpStatistics.cs
- SqlDeflator.cs
- SvcMapFileLoader.cs
- SubMenuStyleCollection.cs
- RenderDataDrawingContext.cs
- WebPartMenuStyle.cs
- HostSecurityManager.cs
- RegexCaptureCollection.cs
- WindowsListViewItem.cs
- OleDbCommand.cs
- MenuCommandService.cs
- FixedSchema.cs
- ObjectListItemCollection.cs
- MsmqIntegrationReceiveParameters.cs
- ParseElement.cs
- MemoryRecordBuffer.cs
- Viewport3DAutomationPeer.cs
- Pen.cs
- SmtpNegotiateAuthenticationModule.cs
- Label.cs
- XNameConverter.cs
- StylusCaptureWithinProperty.cs
- CqlGenerator.cs
- Timer.cs
- ContentType.cs
- MbpInfo.cs
- Point3DCollection.cs
- TimeSpan.cs
- TraceInternal.cs
- MessageQueuePermissionEntryCollection.cs
- RsaSecurityTokenAuthenticator.cs
- LowerCaseStringConverter.cs
- HierarchicalDataBoundControlAdapter.cs
- ValueQuery.cs
- ClientTargetCollection.cs
- TreeBuilder.cs
- SQLInt16Storage.cs
- XPathArrayIterator.cs
- IIS7UserPrincipal.cs
- FunctionDefinition.cs
- CngAlgorithm.cs
- TemplateXamlParser.cs
- ModifyActivitiesPropertyDescriptor.cs
- VirtualPathProvider.cs
- XmlResolver.cs
- HttpApplicationFactory.cs
- COM2ColorConverter.cs
- CorrelationManager.cs
- BitmapPalettes.cs
- ObjectRef.cs
- EndpointAddress10.cs
- TreeNodeCollection.cs
- FileInfo.cs
- OleTxTransaction.cs
- ConstructorNeedsTagAttribute.cs
- FaultHandlingFilter.cs
- XmlFormatWriterGenerator.cs
- IISMapPath.cs
- BaseCollection.cs
- BrowserDefinition.cs
- Perspective.cs
- StaticContext.cs
- AttachedPropertyBrowsableAttribute.cs
- CryptoProvider.cs
- SelectorItemAutomationPeer.cs
- DataGridViewCellMouseEventArgs.cs
- securitycriticaldataClass.cs
- GridItemPatternIdentifiers.cs