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
- DiscoveryDocumentLinksPattern.cs
- MouseGestureValueSerializer.cs
- EndpointNotFoundException.cs
- ReferenceEqualityComparer.cs
- PerformanceCounterNameAttribute.cs
- Pointer.cs
- ImageIndexEditor.cs
- OracleEncoding.cs
- DeploymentSection.cs
- DeferredSelectedIndexReference.cs
- ErrorHandlerFaultInfo.cs
- ProfileEventArgs.cs
- COSERVERINFO.cs
- SoapObjectReader.cs
- ToolStripSplitButton.cs
- SHA384Managed.cs
- NodeFunctions.cs
- RuleSettingsCollection.cs
- DocumentStatusResources.cs
- BoolExpr.cs
- StringUtil.cs
- x509store.cs
- MasterPageParser.cs
- DesignerDataTable.cs
- MemoryMappedViewStream.cs
- DataGridViewToolTip.cs
- WebPartConnectionsConfigureVerb.cs
- SoapElementAttribute.cs
- ExpandableObjectConverter.cs
- DataGridPageChangedEventArgs.cs
- TransformValueSerializer.cs
- PolyBezierSegment.cs
- AutoResizedEvent.cs
- FrameworkElementFactoryMarkupObject.cs
- XhtmlBasicPanelAdapter.cs
- BlurBitmapEffect.cs
- HyperLinkColumn.cs
- IssuerInformation.cs
- ClassDataContract.cs
- DecimalAnimation.cs
- COM2PropertyPageUITypeConverter.cs
- ReaderWriterLock.cs
- MultilineStringConverter.cs
- InvokeProviderWrapper.cs
- OutputCache.cs
- Int64Storage.cs
- JoinElimination.cs
- latinshape.cs
- TypeConverterHelper.cs
- SqlTransaction.cs
- FontDriver.cs
- BitmapEffectInputConnector.cs
- SortDescription.cs
- TakeQueryOptionExpression.cs
- DoubleLinkListEnumerator.cs
- WhiteSpaceTrimStringConverter.cs
- Transaction.cs
- TagPrefixInfo.cs
- WinEventTracker.cs
- ModelTreeEnumerator.cs
- IdentityHolder.cs
- DocumentPageTextView.cs
- ExpandSegment.cs
- ChannelManager.cs
- SqlNotificationEventArgs.cs
- RadioButtonAutomationPeer.cs
- CodePropertyReferenceExpression.cs
- ShapeTypeface.cs
- SqlBuffer.cs
- QilChoice.cs
- DefaultProxySection.cs
- ToolBar.cs
- PhysicalAddress.cs
- SignatureToken.cs
- CheckBoxStandardAdapter.cs
- ChineseLunisolarCalendar.cs
- ServiceChannel.cs
- AsyncOperationManager.cs
- OdbcTransaction.cs
- FormCollection.cs
- ActivityInstanceReference.cs
- ResourceSetExpression.cs
- MobileDeviceCapabilitiesSectionHandler.cs
- Rect3D.cs
- FieldMetadata.cs
- VoiceObjectToken.cs
- SettingsSavedEventArgs.cs
- RawStylusSystemGestureInputReport.cs
- EncryptedKeyIdentifierClause.cs
- DbParameterCollection.cs
- ConnectionProviderAttribute.cs
- ActivityExecutionWorkItem.cs
- ToolStripSeparator.cs
- ToolStripItemRenderEventArgs.cs
- CngKeyBlobFormat.cs
- SerializationInfo.cs
- UnmanagedMemoryStreamWrapper.cs
- GridViewColumnHeader.cs
- LoginUtil.cs
- ValidationSummary.cs