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
- PersonalizationStateInfo.cs
- CriticalExceptions.cs
- WebPartDisplayModeCancelEventArgs.cs
- EpmSourcePathSegment.cs
- HttpRuntime.cs
- ISAPIApplicationHost.cs
- ConditionalExpression.cs
- BuildProvider.cs
- GridView.cs
- XmlDataFileEditor.cs
- TextMarkerSource.cs
- XamlTemplateSerializer.cs
- SqlDataAdapter.cs
- FrameworkContextData.cs
- TextEndOfParagraph.cs
- CharacterMetricsDictionary.cs
- PersistenceTypeAttribute.cs
- DBSchemaTable.cs
- EncoderFallback.cs
- ItemType.cs
- ReachPrintTicketSerializer.cs
- OracleConnectionFactory.cs
- BamlRecordReader.cs
- FolderBrowserDialog.cs
- DataGridViewRowEventArgs.cs
- XmlSchemaExternal.cs
- ViewCellSlot.cs
- XmlSerializationReader.cs
- BeginGetFileNameFromUserRequest.cs
- EpmCustomContentSerializer.cs
- FastEncoderWindow.cs
- LinkConverter.cs
- TypeNameConverter.cs
- DBConcurrencyException.cs
- PagesSection.cs
- XmlName.cs
- Registry.cs
- PerformanceCounterPermissionEntryCollection.cs
- SqlVisitor.cs
- SimpleWorkerRequest.cs
- _AcceptOverlappedAsyncResult.cs
- StrongNameIdentityPermission.cs
- WebPartConnectionsDisconnectVerb.cs
- DataServiceResponse.cs
- XamlStream.cs
- ReadOnlyKeyedCollection.cs
- Duration.cs
- MetaModel.cs
- ActiveXContainer.cs
- DelegateSerializationHolder.cs
- ResourcesGenerator.cs
- EventLogPermission.cs
- QueryAccessibilityHelpEvent.cs
- ClusterSafeNativeMethods.cs
- DesignerSerializationVisibilityAttribute.cs
- TypeToArgumentTypeConverter.cs
- SerializationFieldInfo.cs
- CodeBinaryOperatorExpression.cs
- FlowDocumentPageViewerAutomationPeer.cs
- HierarchicalDataBoundControlAdapter.cs
- ProgressiveCrcCalculatingStream.cs
- TypeUnloadedException.cs
- validationstate.cs
- sqlser.cs
- ImageCodecInfoPrivate.cs
- Style.cs
- SimpleRecyclingCache.cs
- EnvelopedSignatureTransform.cs
- TypeElement.cs
- ResourceDescriptionAttribute.cs
- MaskedTextBoxTextEditorDropDown.cs
- ComponentEvent.cs
- XsdBuilder.cs
- DashStyle.cs
- InkCanvasSelectionAdorner.cs
- QilPatternVisitor.cs
- AuthenticationModuleElementCollection.cs
- SchemaCollectionCompiler.cs
- SweepDirectionValidation.cs
- TypeLibConverter.cs
- EventToken.cs
- ThreadExceptionEvent.cs
- IdentityModelDictionary.cs
- CodeSnippetCompileUnit.cs
- MetadataItemCollectionFactory.cs
- UriTemplateDispatchFormatter.cs
- IOException.cs
- ControlIdConverter.cs
- MethodImplAttribute.cs
- WinInetCache.cs
- PropertyInfoSet.cs
- MatrixIndependentAnimationStorage.cs
- WebBaseEventKeyComparer.cs
- XmlElementList.cs
- CompoundFileDeflateTransform.cs
- WSFederationHttpBindingCollectionElement.cs
- CroppedBitmap.cs
- WebFormDesignerActionService.cs
- RC2.cs
- Normalization.cs