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
- MemoryStream.cs
- IPEndPoint.cs
- HwndKeyboardInputProvider.cs
- embossbitmapeffect.cs
- SourceLineInfo.cs
- MachineKeySection.cs
- KeyFrames.cs
- HtmlContainerControl.cs
- PassportPrincipal.cs
- CombinedHttpChannel.cs
- CounterCreationDataCollection.cs
- MsdtcClusterUtils.cs
- IOException.cs
- DropDownList.cs
- odbcmetadatafactory.cs
- XmlSchemaAttributeGroupRef.cs
- DBDataPermission.cs
- Border.cs
- SemanticResultKey.cs
- WpfWebRequestHelper.cs
- PathSegmentCollection.cs
- WebPartsPersonalization.cs
- DataPagerFieldItem.cs
- HandledEventArgs.cs
- RichTextBoxConstants.cs
- ItemMap.cs
- SwitchElementsCollection.cs
- AttachmentService.cs
- x509store.cs
- WindowsFormsHostAutomationPeer.cs
- ListControl.cs
- WindowsScroll.cs
- PolyQuadraticBezierSegment.cs
- ActivityExecutionContext.cs
- _NTAuthentication.cs
- ContextMenu.cs
- DataSourceView.cs
- PointValueSerializer.cs
- RoutedEventConverter.cs
- Publisher.cs
- _NetRes.cs
- CodeMethodInvokeExpression.cs
- SystemIcmpV6Statistics.cs
- DialogWindow.cs
- ListViewUpdatedEventArgs.cs
- BuilderInfo.cs
- Message.cs
- TextSearch.cs
- GetPageNumberCompletedEventArgs.cs
- SessionPageStateSection.cs
- Quaternion.cs
- Win32MouseDevice.cs
- CommandBindingCollection.cs
- PropertyMappingExceptionEventArgs.cs
- RuntimeConfigLKG.cs
- UInt32Converter.cs
- UniqueIdentifierService.cs
- Matrix.cs
- InertiaRotationBehavior.cs
- BitmapImage.cs
- BaseCodeDomTreeGenerator.cs
- RadioButtonPopupAdapter.cs
- ChannelBinding.cs
- AmbiguousMatchException.cs
- XamlStyleSerializer.cs
- ValidatorUtils.cs
- LoginName.cs
- FileLogRecordEnumerator.cs
- RelatedEnd.cs
- SystemGatewayIPAddressInformation.cs
- BoundPropertyEntry.cs
- CodeAttributeDeclaration.cs
- DataGridViewRowsAddedEventArgs.cs
- InteropBitmapSource.cs
- InvalidProgramException.cs
- Int32Animation.cs
- PopupRoot.cs
- DesignerCommandAdapter.cs
- RowCache.cs
- SafeLocalMemHandle.cs
- GeneralTransform.cs
- WSDualHttpSecurityMode.cs
- DataBoundControlHelper.cs
- SchemaManager.cs
- EventMappingSettingsCollection.cs
- WebDisplayNameAttribute.cs
- XmlSignificantWhitespace.cs
- RijndaelManagedTransform.cs
- DocumentReferenceCollection.cs
- ClientFormsIdentity.cs
- BaseParagraph.cs
- EnumValidator.cs
- Point3DKeyFrameCollection.cs
- PolyQuadraticBezierSegment.cs
- RuntimeConfigurationRecord.cs
- BitmapImage.cs
- SqlInternalConnectionSmi.cs
- TraceHwndHost.cs
- VectorKeyFrameCollection.cs
- EventLogSession.cs