Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataEntity / System / Data / Common / Utils / Boolean / Vertex.cs / 1 / Vertex.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
namespace System.Data.Common.Utils.Boolean
{
using System.Diagnostics;
using System.Globalization;
///
/// A node in a Reduced Ordered Boolean Decision Diagram. Reads as:
///
/// if 'Variable' then 'Then' else 'Else'
///
/// Invariant: the Then and Else children must refer to 'deeper' variables,
/// or variables with a higher value. Otherwise, the graph is not 'Ordered'.
/// All creation of vertices is mediated by the Solver class which ensures
/// each vertex is unique. Otherwise, the graph is not 'Reduced'.
///
sealed class Vertex : IEquatable
{
///
/// Initializes a sink BDD node (zero or one)
///
private Vertex()
{
this.Variable = int.MaxValue;
this.Children = new Vertex[] { };
}
internal Vertex(int variable, Vertex[] children)
{
EntityUtil.BoolExprAssert(variable < int.MaxValue,
"exceeded number of supported variables");
AssertConstructorArgumentsValid(variable, children);
this.Variable = variable;
this.Children = children;
}
[Conditional("DEBUG")]
private static void AssertConstructorArgumentsValid(int variable, Vertex[] children)
{
Debug.Assert(null != children, "internal vertices must define children");
Debug.Assert(2 <= children.Length, "internal vertices must have at least two children");
Debug.Assert(0 < variable, "internal vertices must have 0 < variable");
foreach (Vertex child in children)
{
Debug.Assert(variable < child.Variable, "children must have greater variable");
}
}
///
/// Sink node representing the Boolean function '1' (true)
///
internal static readonly Vertex One = new Vertex();
///
/// Sink node representing the Boolean function '0' (false)
///
internal static readonly Vertex Zero = new Vertex();
///
/// Gets the variable tested by this vertex. If this is a sink node, returns
/// int.MaxValue since there is no variable to test (and since this is a leaf,
/// this non-existent variable is 'deeper' than any existing variable; the
/// variable value is larger than any real variable)
///
internal readonly int Variable;
///
/// Note: do not modify elements.
/// Gets the result when Variable evaluates to true. If this is a sink node,
/// returns null.
///
internal readonly Vertex[] Children;
///
/// Returns true if this is '1'.
///
internal bool IsOne()
{
return object.ReferenceEquals(Vertex.One, this);
}
///
/// Returns true if this is '0'.
///
internal bool IsZero()
{
return object.ReferenceEquals(Vertex.Zero, this);
}
///
/// Returns true if this is '0' or '1'.
///
internal bool IsSink()
{
return Variable == int.MaxValue;
}
public bool Equals(Vertex other)
{
return object.ReferenceEquals(this, other);
}
public override bool Equals(object obj)
{
Debug.Fail("used typed Equals");
return base.Equals(obj);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override string ToString()
{
if (IsOne())
{
return "_1_";
}
if (IsZero())
{
return "_0_";
}
return String.Format(CultureInfo.InvariantCulture, "<{0}, {1}>", Variable, StringUtil.ToCommaSeparatedString(Children));
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
namespace System.Data.Common.Utils.Boolean
{
using System.Diagnostics;
using System.Globalization;
///
/// A node in a Reduced Ordered Boolean Decision Diagram. Reads as:
///
/// if 'Variable' then 'Then' else 'Else'
///
/// Invariant: the Then and Else children must refer to 'deeper' variables,
/// or variables with a higher value. Otherwise, the graph is not 'Ordered'.
/// All creation of vertices is mediated by the Solver class which ensures
/// each vertex is unique. Otherwise, the graph is not 'Reduced'.
///
sealed class Vertex : IEquatable
{
///
/// Initializes a sink BDD node (zero or one)
///
private Vertex()
{
this.Variable = int.MaxValue;
this.Children = new Vertex[] { };
}
internal Vertex(int variable, Vertex[] children)
{
EntityUtil.BoolExprAssert(variable < int.MaxValue,
"exceeded number of supported variables");
AssertConstructorArgumentsValid(variable, children);
this.Variable = variable;
this.Children = children;
}
[Conditional("DEBUG")]
private static void AssertConstructorArgumentsValid(int variable, Vertex[] children)
{
Debug.Assert(null != children, "internal vertices must define children");
Debug.Assert(2 <= children.Length, "internal vertices must have at least two children");
Debug.Assert(0 < variable, "internal vertices must have 0 < variable");
foreach (Vertex child in children)
{
Debug.Assert(variable < child.Variable, "children must have greater variable");
}
}
///
/// Sink node representing the Boolean function '1' (true)
///
internal static readonly Vertex One = new Vertex();
///
/// Sink node representing the Boolean function '0' (false)
///
internal static readonly Vertex Zero = new Vertex();
///
/// Gets the variable tested by this vertex. If this is a sink node, returns
/// int.MaxValue since there is no variable to test (and since this is a leaf,
/// this non-existent variable is 'deeper' than any existing variable; the
/// variable value is larger than any real variable)
///
internal readonly int Variable;
///
/// Note: do not modify elements.
/// Gets the result when Variable evaluates to true. If this is a sink node,
/// returns null.
///
internal readonly Vertex[] Children;
///
/// Returns true if this is '1'.
///
internal bool IsOne()
{
return object.ReferenceEquals(Vertex.One, this);
}
///
/// Returns true if this is '0'.
///
internal bool IsZero()
{
return object.ReferenceEquals(Vertex.Zero, this);
}
///
/// Returns true if this is '0' or '1'.
///
internal bool IsSink()
{
return Variable == int.MaxValue;
}
public bool Equals(Vertex other)
{
return object.ReferenceEquals(this, other);
}
public override bool Equals(object obj)
{
Debug.Fail("used typed Equals");
return base.Equals(obj);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override string ToString()
{
if (IsOne())
{
return "_1_";
}
if (IsZero())
{
return "_0_";
}
return String.Format(CultureInfo.InvariantCulture, "<{0}, {1}>", Variable, StringUtil.ToCommaSeparatedString(Children));
}
}
}
// 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
- DataGridViewSelectedRowCollection.cs
- TemplatedMailWebEventProvider.cs
- EmbeddedObject.cs
- DocumentGridContextMenu.cs
- CellIdBoolean.cs
- EventManager.cs
- ReadOnlyCollection.cs
- ContractMethodInfo.cs
- SessionStateContainer.cs
- DataBindingHandlerAttribute.cs
- ActivationArguments.cs
- translator.cs
- SecurityManager.cs
- DecoderNLS.cs
- OdbcEnvironment.cs
- EdmFunction.cs
- ContentPropertyAttribute.cs
- NestPullup.cs
- SByteConverter.cs
- DataBoundControlActionList.cs
- SafeWaitHandle.cs
- IntranetCredentialPolicy.cs
- FaultReasonText.cs
- LogExtentCollection.cs
- ConfigXmlAttribute.cs
- AnimatedTypeHelpers.cs
- LookupNode.cs
- ArrayConverter.cs
- WindowsGrip.cs
- LookupBindingPropertiesAttribute.cs
- BamlBinaryWriter.cs
- SimpleBitVector32.cs
- ControlDesigner.cs
- Walker.cs
- DataSet.cs
- Menu.cs
- InputLanguageEventArgs.cs
- HttpValueCollection.cs
- StructuralComparisons.cs
- _SslState.cs
- StatusBarItemAutomationPeer.cs
- GAC.cs
- ControlEvent.cs
- XmlDocumentViewSchema.cs
- Timer.cs
- ToolStripPanel.cs
- XmlEncodedRawTextWriter.cs
- ILGenerator.cs
- SettingsPropertyIsReadOnlyException.cs
- EdmProviderManifest.cs
- Grid.cs
- DataControlLinkButton.cs
- PropVariant.cs
- Padding.cs
- MaskedTextBoxDesignerActionList.cs
- SoapHeaderAttribute.cs
- MulticastOption.cs
- HitTestWithPointDrawingContextWalker.cs
- Assert.cs
- MonitoringDescriptionAttribute.cs
- TimeIntervalCollection.cs
- HttpListenerTimeoutManager.cs
- ListItemCollection.cs
- ChtmlPhoneCallAdapter.cs
- BindingExpressionBase.cs
- RequestStatusBarUpdateEventArgs.cs
- TypeCollectionDesigner.xaml.cs
- ProxyGenerator.cs
- ProcessModelSection.cs
- PartBasedPackageProperties.cs
- XmlDictionaryWriter.cs
- XslNumber.cs
- CodeLabeledStatement.cs
- AuthenticationModuleElement.cs
- ADRoleFactoryConfiguration.cs
- QuotedPairReader.cs
- ArglessEventHandlerProxy.cs
- OutOfMemoryException.cs
- OperationParameterInfo.cs
- BrowserInteropHelper.cs
- TargetException.cs
- MdImport.cs
- XmlSequenceWriter.cs
- SqlDataSource.cs
- HtmlInputSubmit.cs
- XmlTypeAttribute.cs
- RotateTransform3D.cs
- StringReader.cs
- SourceInterpreter.cs
- DataServiceOperationContext.cs
- KeyedCollection.cs
- TextEndOfLine.cs
- ClientProxyGenerator.cs
- XmlChoiceIdentifierAttribute.cs
- GridViewCommandEventArgs.cs
- ExeConfigurationFileMap.cs
- SystemSounds.cs
- StructuredTypeInfo.cs
- OleStrCAMarshaler.cs
- JavaScriptSerializer.cs