Code:
/ FX-1434 / FX-1434 / 1.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
- EntityRecordInfo.cs
- SimpleBitVector32.cs
- __ConsoleStream.cs
- AssertFilter.cs
- DateTimeConverter.cs
- SetterBaseCollection.cs
- ObjectContextServiceProvider.cs
- WebPartCollection.cs
- Drawing.cs
- SimpleHandlerFactory.cs
- StateMachineAction.cs
- ExecutionScope.cs
- CompositionCommandSet.cs
- EntityViewGenerator.cs
- IntegerValidatorAttribute.cs
- Condition.cs
- ColorAnimationUsingKeyFrames.cs
- HashSetDebugView.cs
- JoinGraph.cs
- ParallelLoopState.cs
- CompositeKey.cs
- metadatamappinghashervisitor.cs
- GenericRootAutomationPeer.cs
- EncryptedXml.cs
- ProfileGroupSettingsCollection.cs
- ResXFileRef.cs
- WinEventQueueItem.cs
- DeploymentExceptionMapper.cs
- CriticalExceptions.cs
- FormViewModeEventArgs.cs
- XPathNode.cs
- KeyConstraint.cs
- RegistrySecurity.cs
- EntityDataSourceWrapperCollection.cs
- RegisteredExpandoAttribute.cs
- TextEncodedRawTextWriter.cs
- StandardCommands.cs
- OrderedDictionary.cs
- GenericUriParser.cs
- PropertyReferenceSerializer.cs
- RunInstallerAttribute.cs
- formatstringdialog.cs
- AddInActivator.cs
- ExceptionHelpers.cs
- DataGridViewCellStateChangedEventArgs.cs
- ActivityInterfaces.cs
- MsmqChannelFactory.cs
- InternalDispatchObject.cs
- PtsContext.cs
- DataGridViewComboBoxCell.cs
- HuffCodec.cs
- CriticalFileToken.cs
- ControlBindingsCollection.cs
- AudioStateChangedEventArgs.cs
- RangeContentEnumerator.cs
- SearchForVirtualItemEventArgs.cs
- InkSerializer.cs
- SqlConnectionHelper.cs
- SqlTypeConverter.cs
- QueryComponents.cs
- EntityDataSourceColumn.cs
- ToolStripSeparatorRenderEventArgs.cs
- ProviderConnectionPointCollection.cs
- WebPartZoneCollection.cs
- ClientProtocol.cs
- SmiEventSink_DeferedProcessing.cs
- GlobalDataBindingHandler.cs
- XmlSerializationGeneratedCode.cs
- TemplatedWizardStep.cs
- DetailsViewRowCollection.cs
- AxHost.cs
- DataGridViewColumnCollection.cs
- Vector3DAnimationBase.cs
- InputLanguageProfileNotifySink.cs
- QEncodedStream.cs
- AnnotationHelper.cs
- CallbackWrapper.cs
- LookupBindingPropertiesAttribute.cs
- ToolStripSplitStackLayout.cs
- LocalizationCodeDomSerializer.cs
- ItemCollectionEditor.cs
- QilTargetType.cs
- BamlStream.cs
- Win32Interop.cs
- SamlDoNotCacheCondition.cs
- TabletDeviceInfo.cs
- MulticastDelegate.cs
- MetadataArtifactLoader.cs
- QilStrConcat.cs
- Activity.cs
- WebPartZoneDesigner.cs
- WmlValidatorAdapter.cs
- StylusPointPropertyInfo.cs
- HttpResponseInternalBase.cs
- ShaperBuffers.cs
- FormViewRow.cs
- SecurityUtils.cs
- ImageMetadata.cs
- _IPv4Address.cs
- XamlReaderConstants.cs