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
- ZipIOExtraField.cs
- BCLDebug.cs
- WasAdminWrapper.cs
- Matrix3DConverter.cs
- InputLanguageSource.cs
- CodeTypeMember.cs
- XmlNodeReader.cs
- XmlElementCollection.cs
- ScriptResourceInfo.cs
- DataServiceQueryOfT.cs
- EventLogConfiguration.cs
- BitSet.cs
- StyleCollection.cs
- Pair.cs
- ResourceProviderFactory.cs
- xmlglyphRunInfo.cs
- XmlUnspecifiedAttribute.cs
- TrackBar.cs
- JsonWriter.cs
- FieldValue.cs
- DecoderExceptionFallback.cs
- GridViewUpdatedEventArgs.cs
- AttachmentService.cs
- AuthenticationModuleElementCollection.cs
- SecurityElementBase.cs
- StaticFileHandler.cs
- HttpContext.cs
- MsdtcClusterUtils.cs
- MembershipAdapter.cs
- Evaluator.cs
- WebRequest.cs
- Span.cs
- CollectionConverter.cs
- TemplateNameScope.cs
- DynamicILGenerator.cs
- BufferModesCollection.cs
- ConfigurationSection.cs
- DataControlPagerLinkButton.cs
- TextServicesCompartmentEventSink.cs
- OledbConnectionStringbuilder.cs
- SystemResourceKey.cs
- PeerToPeerException.cs
- CacheChildrenQuery.cs
- RuleSet.cs
- precedingsibling.cs
- UIElementHelper.cs
- WorkflowRuntimeServiceElement.cs
- QilLoop.cs
- ClientSponsor.cs
- ServiceHttpHandlerFactory.cs
- MemoryMappedView.cs
- CollectionViewSource.cs
- RpcResponse.cs
- LiteralText.cs
- CompilationLock.cs
- HttpVersion.cs
- RequestValidator.cs
- BackStopAuthenticationModule.cs
- LinqDataSourceDisposeEventArgs.cs
- ImageButton.cs
- IndexedString.cs
- oledbmetadatacolumnnames.cs
- TypeSource.cs
- MULTI_QI.cs
- NonClientArea.cs
- DbConnectionPool.cs
- SqlReorderer.cs
- VariableQuery.cs
- SHA512Managed.cs
- ListControlDesigner.cs
- ColorContextHelper.cs
- TypeHelper.cs
- DateTimeUtil.cs
- ContentPlaceHolder.cs
- PlacementWorkspace.cs
- _LocalDataStoreMgr.cs
- SoundPlayer.cs
- PointLight.cs
- Root.cs
- TextTreeTextElementNode.cs
- HotCommands.cs
- CodeIdentifier.cs
- GetPageCompletedEventArgs.cs
- TextRange.cs
- SelectionPattern.cs
- BooleanFacetDescriptionElement.cs
- LineVisual.cs
- CodeDomSerializer.cs
- HtmlInputControl.cs
- RegisteredScript.cs
- BasicExpandProvider.cs
- IpcServerChannel.cs
- SequenceFullException.cs
- Context.cs
- OSFeature.cs
- TextDecoration.cs
- XmlDesigner.cs
- NameValueConfigurationCollection.cs
- Executor.cs
- SerializableAttribute.cs