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
- SqlRecordBuffer.cs
- HierarchicalDataTemplate.cs
- SmtpFailedRecipientException.cs
- WebFormsRootDesigner.cs
- TrustSection.cs
- DocumentOrderComparer.cs
- ServiceHost.cs
- SignerInfo.cs
- GenericIdentity.cs
- SafeRightsManagementHandle.cs
- ClientWindowsAuthenticationMembershipProvider.cs
- RectAnimation.cs
- ValidationPropertyAttribute.cs
- CustomAttributeBuilder.cs
- SafeWaitHandle.cs
- ProfilePropertyMetadata.cs
- __Filters.cs
- LowerCaseStringConverter.cs
- DesignerDataTable.cs
- SqlDataSourceCustomCommandPanel.cs
- IPEndPoint.cs
- CompilerLocalReference.cs
- XmlConvert.cs
- ActiveDocumentEvent.cs
- FileInfo.cs
- TriggerCollection.cs
- CommandManager.cs
- RegexCapture.cs
- CursorConverter.cs
- ListBox.cs
- DrawingServices.cs
- BindingCompleteEventArgs.cs
- MemoryFailPoint.cs
- SerializerProvider.cs
- ExtensionSurface.cs
- RowVisual.cs
- NamespaceInfo.cs
- MimeImporter.cs
- DataBoundLiteralControl.cs
- CodeEventReferenceExpression.cs
- MobileSysDescriptionAttribute.cs
- EnumMemberAttribute.cs
- StreamUpgradeInitiator.cs
- GeometryHitTestParameters.cs
- ContextMenuAutomationPeer.cs
- SystemWebSectionGroup.cs
- WebPartTransformerAttribute.cs
- Mapping.cs
- SchemaNotation.cs
- ApplicationHost.cs
- TemplateLookupAction.cs
- LinearGradientBrush.cs
- UserControlAutomationPeer.cs
- SystemIcmpV6Statistics.cs
- DiscoveryUtility.cs
- RankException.cs
- GraphicsContainer.cs
- _ChunkParse.cs
- StackOverflowException.cs
- ApplicationDirectory.cs
- RepeaterCommandEventArgs.cs
- XmlDocumentType.cs
- MeshGeometry3D.cs
- BrowserTree.cs
- WindowsToolbar.cs
- MsmqTransportSecurityElement.cs
- AutomationProperty.cs
- StateItem.cs
- SingleAnimation.cs
- DocumentOrderComparer.cs
- SqlClientFactory.cs
- PermissionSet.cs
- Rect3DValueSerializer.cs
- ActivityDesignerHighlighter.cs
- MouseEvent.cs
- OverrideMode.cs
- util.cs
- TargetConverter.cs
- SocketSettings.cs
- DataProtection.cs
- HierarchicalDataBoundControl.cs
- QueryConverter.cs
- RemoteWebConfigurationHost.cs
- EventHandlerService.cs
- SafeNativeMethodsMilCoreApi.cs
- DataGridViewTextBoxCell.cs
- EdmEntityTypeAttribute.cs
- DataServiceQueryOfT.cs
- CustomSignedXml.cs
- DPCustomTypeDescriptor.cs
- InputLanguage.cs
- OperationPerformanceCounters.cs
- StylusLogic.cs
- ServiceOperationListItem.cs
- IPEndPointCollection.cs
- ThreadPool.cs
- HwndSourceKeyboardInputSite.cs
- ImageAttributes.cs
- HeaderedItemsControl.cs
- GlyphingCache.cs