Esempio n. 1
0
 /// <summary>
 /// Constructs a new constraint for the given variable and range.
 /// </summary>
 /// <param name="variable">Variable in constraint.</param>
 /// <param name="range">Range of constraint.</param>
 internal DomainConstraint(DomainVariable <T_Variable, T_Element> variable, Set <T_Element> range)
 {
     Debug.Assert(null != variable && null != range);
     _variable = variable;
     _range    = range.AsReadOnly();
     _hashCode = _variable.GetHashCode() ^ _range.GetElementsHashCode();
 }
Esempio n. 2
0
        public override bool Equals(object obj)
        {
            if (Object.ReferenceEquals(this, obj))
            {
                return(true);
            }
            DomainVariable <T_Variable, T_Element> other = obj as DomainVariable <T_Variable, T_Element>;

            if (null == other)
            {
                return(false);
            }
            if (_hashCode != other._hashCode)
            {
                return(false);
            }
            return(_identifierComparer.Equals(_identifier, other._identifier) && _domain.SetEquals(other._domain));
        }
Esempio n. 3
0
 /// <summary>
 /// Constructor supporting a singleton range domain constraint
 /// </summary>
 internal DomainConstraint(DomainVariable <T_Variable, T_Element> variable, T_Element element)
     : this(variable, new Set <T_Element>(new T_Element[] { element }).MakeReadOnly())
 {
 }