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
- ActionMismatchAddressingException.cs
- TypeElement.cs
- QilStrConcat.cs
- EnvironmentPermission.cs
- ValidationSummary.cs
- InheritanceContextChangedEventManager.cs
- SqlVisitor.cs
- WebFaultClientMessageInspector.cs
- Win32.cs
- MasterPage.cs
- XmlSerializableServices.cs
- oledbconnectionstring.cs
- EntitySqlQueryCacheKey.cs
- CompilerTypeWithParams.cs
- OdbcTransaction.cs
- AssemblyName.cs
- DesignerDataTableBase.cs
- RuleSettings.cs
- ToolboxItemCollection.cs
- CodePageUtils.cs
- Int32Collection.cs
- OleDbParameter.cs
- ColumnWidthChangedEvent.cs
- CryptoKeySecurity.cs
- ToolStripProgressBar.cs
- ApplicationDirectory.cs
- ELinqQueryState.cs
- ArgumentException.cs
- AspNetHostingPermission.cs
- FileAccessException.cs
- Polyline.cs
- LocalizationComments.cs
- LinqDataView.cs
- AsymmetricSecurityProtocol.cs
- TextCharacters.cs
- Dispatcher.cs
- Soap.cs
- DoubleAnimationUsingPath.cs
- WebBrowsableAttribute.cs
- PenContext.cs
- Polyline.cs
- MemberDescriptor.cs
- IOThreadTimer.cs
- PerfService.cs
- TextTreeText.cs
- PeerValidationBehavior.cs
- DataGridViewDataErrorEventArgs.cs
- StoreItemCollection.cs
- LicenseContext.cs
- figurelengthconverter.cs
- BinaryNode.cs
- Cloud.cs
- XmlTextWriter.cs
- EntitySetBaseCollection.cs
- Formatter.cs
- RegexMatch.cs
- ScaleTransform.cs
- StrokeCollection.cs
- ProviderCollection.cs
- CheckBoxBaseAdapter.cs
- Iis7Helper.cs
- WindowsRichEditRange.cs
- cookiecollection.cs
- CalendarTable.cs
- printdlgexmarshaler.cs
- FocusTracker.cs
- TextParentUndoUnit.cs
- SerializableAttribute.cs
- Line.cs
- _HelperAsyncResults.cs
- CatalogPart.cs
- CounterCreationDataConverter.cs
- FrameAutomationPeer.cs
- PathHelper.cs
- CSharpCodeProvider.cs
- XPathNodeHelper.cs
- PropertyPathWorker.cs
- WebPartHeaderCloseVerb.cs
- ProcessInputEventArgs.cs
- StartFileNameEditor.cs
- CodeTypeOfExpression.cs
- ModifyActivitiesPropertyDescriptor.cs
- DesignerDeviceConfig.cs
- UserValidatedEventArgs.cs
- XomlCompilerHelpers.cs
- ApplicationBuildProvider.cs
- Attributes.cs
- IListConverters.cs
- DBProviderConfigurationHandler.cs
- CorePropertiesFilter.cs
- RecognizedPhrase.cs
- BufferBuilder.cs
- Converter.cs
- XmlSchemaComplexContentExtension.cs
- ScriptBehaviorDescriptor.cs
- PrintDialog.cs
- UnionExpr.cs
- ContainsRowNumberChecker.cs
- TextSearch.cs
- AttributeEmitter.cs