Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / Query / ResultAssembly / BitVec.cs / 3 / BitVec.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], [....] //--------------------------------------------------------------------- namespace System.Data.Query.ResultAssembly { using System.Diagnostics; using System.Text; ////// BitVector helper class; used to keep track of the used columns /// in the result assembly. /// ////// BitVec can be a struct because it contains a readonly reference to an int[]. /// This code is a copy of System.Collections.BitArray so that we can have an efficient implementation of Minus. /// internal struct BitVec { private readonly int[] m_array; private readonly int m_length; [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal BitVec(int length) { Debug.Assert(0 < length, "zero length"); m_array = new int[(length + 31) / 32]; m_length = length; } internal int Count { get { return m_length; } } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal void Set(int index) { Debug.Assert(unchecked((uint)index < (uint)m_length), "index out of range"); m_array[index / 32] |= (1 << (index % 32)); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal void ClearAll() { for (int i = 0; i < m_array.Length; i++) { m_array[i] = 0; } } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal bool IsEmpty() { for (int i = 0; i < m_array.Length; i++) { if (0 != m_array[i]) { return false; } } return true; } internal bool IsSet(int index) { Debug.Assert(unchecked((uint)index < (uint)m_length), "index out of range"); return (m_array[index / 32] & (1 << (index % 32))) != 0; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal void Or(BitVec value) { Debug.Assert(m_length == value.m_length, "unequal sized bitvec"); for (int i = 0; i < m_array.Length; i++) { m_array[i] |= value.m_array[i]; } } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal void Minus(BitVec value) { Debug.Assert(m_length == value.m_length, "unequal sized bitvec"); for (int i = 0; i < m_array.Length; i++) { m_array[i] &= ~value.m_array[i]; } } public override string ToString() { StringBuilder sb = new StringBuilder(3 * Count); string separator = string.Empty; for (int i = 0; i < Count; i++) { if (IsSet(i)) { sb.Append(separator); sb.Append(i); separator = ","; } } return sb.ToString(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], [....] //--------------------------------------------------------------------- namespace System.Data.Query.ResultAssembly { using System.Diagnostics; using System.Text; ////// BitVector helper class; used to keep track of the used columns /// in the result assembly. /// ////// BitVec can be a struct because it contains a readonly reference to an int[]. /// This code is a copy of System.Collections.BitArray so that we can have an efficient implementation of Minus. /// internal struct BitVec { private readonly int[] m_array; private readonly int m_length; [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal BitVec(int length) { Debug.Assert(0 < length, "zero length"); m_array = new int[(length + 31) / 32]; m_length = length; } internal int Count { get { return m_length; } } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal void Set(int index) { Debug.Assert(unchecked((uint)index < (uint)m_length), "index out of range"); m_array[index / 32] |= (1 << (index % 32)); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal void ClearAll() { for (int i = 0; i < m_array.Length; i++) { m_array[i] = 0; } } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal bool IsEmpty() { for (int i = 0; i < m_array.Length; i++) { if (0 != m_array[i]) { return false; } } return true; } internal bool IsSet(int index) { Debug.Assert(unchecked((uint)index < (uint)m_length), "index out of range"); return (m_array[index / 32] & (1 << (index % 32))) != 0; } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal void Or(BitVec value) { Debug.Assert(m_length == value.m_length, "unequal sized bitvec"); for (int i = 0; i < m_array.Length; i++) { m_array[i] |= value.m_array[i]; } } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal void Minus(BitVec value) { Debug.Assert(m_length == value.m_length, "unequal sized bitvec"); for (int i = 0; i < m_array.Length; i++) { m_array[i] &= ~value.m_array[i]; } } public override string ToString() { StringBuilder sb = new StringBuilder(3 * Count); string separator = string.Empty; for (int i = 0; i < Count; i++) { if (IsSet(i)) { sb.Append(separator); sb.Append(i); separator = ","; } } return sb.ToString(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TemplateBindingExtension.cs
- WhitespaceSignificantCollectionAttribute.cs
- MulticastNotSupportedException.cs
- ProviderException.cs
- VScrollProperties.cs
- RegisteredExpandoAttribute.cs
- UTF7Encoding.cs
- FrameworkTextComposition.cs
- NonBatchDirectoryCompiler.cs
- CodeTypeReferenceExpression.cs
- EmptyEnumerator.cs
- InternalMappingException.cs
- XmlConverter.cs
- DynamicRendererThreadManager.cs
- WrapPanel.cs
- IResourceProvider.cs
- AxImporter.cs
- XsltFunctions.cs
- CustomActivityDesigner.cs
- Rotation3DAnimationUsingKeyFrames.cs
- EdmComplexTypeAttribute.cs
- BufferModeSettings.cs
- CodeAssignStatement.cs
- ResetableIterator.cs
- CodeTypeDeclarationCollection.cs
- TemplatedAdorner.cs
- RegexGroupCollection.cs
- SQLStringStorage.cs
- CommandDesigner.cs
- Overlapped.cs
- CTreeGenerator.cs
- FileRegion.cs
- basecomparevalidator.cs
- MsmqHostedTransportConfiguration.cs
- FontWeightConverter.cs
- WriterOutput.cs
- DotAtomReader.cs
- NativeCompoundFileAPIs.cs
- DateTimeFormatInfo.cs
- TransformerTypeCollection.cs
- TypefaceCollection.cs
- GregorianCalendarHelper.cs
- ClockGroup.cs
- RowType.cs
- Vector3DIndependentAnimationStorage.cs
- DynamicResourceExtension.cs
- ArrayList.cs
- ServicePrincipalNameElement.cs
- OperationContext.cs
- log.cs
- SessionEndedEventArgs.cs
- SelectedDatesCollection.cs
- OdbcConnectionHandle.cs
- AuditLog.cs
- panel.cs
- IdentityNotMappedException.cs
- XMLUtil.cs
- TimersDescriptionAttribute.cs
- TrackBarRenderer.cs
- __Error.cs
- ResourcesGenerator.cs
- NotSupportedException.cs
- WindowsSlider.cs
- WebPartChrome.cs
- PhysicalAddress.cs
- DrawingContextDrawingContextWalker.cs
- TypeBuilder.cs
- CompiledRegexRunnerFactory.cs
- SafeRegistryHandle.cs
- TokenBasedSetEnumerator.cs
- RoleManagerEventArgs.cs
- DataRowChangeEvent.cs
- WinEventQueueItem.cs
- CompModHelpers.cs
- SmiContext.cs
- VersionedStream.cs
- IPipelineRuntime.cs
- UnSafeCharBuffer.cs
- GenericNameHandler.cs
- ListenerHandler.cs
- DataGridViewCellStyle.cs
- UnsafeNativeMethods.cs
- BoundingRectTracker.cs
- TrustManager.cs
- TabletCollection.cs
- OLEDB_Enum.cs
- ToolStripDropTargetManager.cs
- IIS7WorkerRequest.cs
- HelpProvider.cs
- SqlUserDefinedAggregateAttribute.cs
- DocumentViewer.cs
- ComplexPropertyEntry.cs
- MissingManifestResourceException.cs
- SiteMap.cs
- EventProxy.cs
- DbConnectionPoolGroup.cs
- exports.cs
- MimeXmlReflector.cs
- SafeFindHandle.cs
- RelationshipType.cs