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
- ObjectSpanRewriter.cs
- MarginCollapsingState.cs
- SharedStatics.cs
- FlowchartStart.xaml.cs
- DocumentSequenceHighlightLayer.cs
- ProxyWebPart.cs
- Literal.cs
- BehaviorDragDropEventArgs.cs
- StructuralObject.cs
- ElementNotEnabledException.cs
- ellipse.cs
- WorkflowLayouts.cs
- StylusPointCollection.cs
- Point3D.cs
- BitStack.cs
- LookupBindingPropertiesAttribute.cs
- TextSelectionHelper.cs
- SqlDuplicator.cs
- Error.cs
- StringReader.cs
- MergeFilterQuery.cs
- ZipIOModeEnforcingStream.cs
- RegexGroup.cs
- MemoryFailPoint.cs
- XmlElementAttributes.cs
- OdbcFactory.cs
- DataGridState.cs
- ThreadStateException.cs
- StorageComplexTypeMapping.cs
- ListComponentEditor.cs
- TreeNodeStyle.cs
- TreeViewDesigner.cs
- DeleteHelper.cs
- BrowsableAttribute.cs
- OleDbConnectionFactory.cs
- SqlIdentifier.cs
- DataFieldCollectionEditor.cs
- TreeWalker.cs
- IsolatedStorage.cs
- FollowerQueueCreator.cs
- DataGridColumn.cs
- LinkClickEvent.cs
- WebHeaderCollection.cs
- StateWorkerRequest.cs
- XmlSchemaElement.cs
- SqlBulkCopyColumnMapping.cs
- WebServiceTypeData.cs
- ProviderCollection.cs
- MLangCodePageEncoding.cs
- DataSourceExpression.cs
- InputEventArgs.cs
- DataTableNewRowEvent.cs
- TableLayoutRowStyleCollection.cs
- figurelength.cs
- SafePointer.cs
- BindableTemplateBuilder.cs
- TypedElement.cs
- EntityContainer.cs
- Constraint.cs
- EmbeddedMailObjectCollectionEditor.cs
- HtmlAnchor.cs
- ConfigurationManagerInternal.cs
- ListViewDeletedEventArgs.cs
- XmlSchemaAll.cs
- SafeRightsManagementHandle.cs
- RectValueSerializer.cs
- StreamSecurityUpgradeAcceptor.cs
- ScrollProperties.cs
- ByteConverter.cs
- InstanceDataCollection.cs
- _AutoWebProxyScriptHelper.cs
- XsltLoader.cs
- SafeSystemMetrics.cs
- ConditionalAttribute.cs
- Literal.cs
- TextEditorLists.cs
- BitmapFrameDecode.cs
- StorageTypeMapping.cs
- CompositionTarget.cs
- SequenceNumber.cs
- SchemaElementDecl.cs
- Walker.cs
- TextEffectResolver.cs
- ThreadExceptionEvent.cs
- UnknownWrapper.cs
- XhtmlCssHandler.cs
- TreeIterators.cs
- GradientBrush.cs
- SharedDp.cs
- NegatedConstant.cs
- EvidenceBase.cs
- Rules.cs
- MarkupCompilePass1.cs
- EntityKey.cs
- ProtectedProviderSettings.cs
- SqlDependencyListener.cs
- DispatcherOperation.cs
- IndexedGlyphRun.cs
- ListItemCollection.cs
- PrivilegedConfigurationManager.cs