Пример #1
0
        internal override bool SubtractImpl(FeatureValue other, VariableBindings varBindings, IDictionary <FeatureStruct, ISet <FeatureStruct> > visited)
        {
            SimpleFeatureValue otherSfv;

            if (!Dereference(other, out otherSfv))
            {
                return(true);
            }

            if (!IsVariable && !otherSfv.IsVariable)
            {
                ExceptWith(false, otherSfv, false);
            }
            else if (IsVariable && !otherSfv.IsVariable)
            {
                SimpleFeatureValue binding;
                if (varBindings.TryGetValue(VariableName, out binding))
                {
                    UnionWith(false, binding, !Agree);
                    ExceptWith(false, otherSfv, false);
                    VariableName = null;
                }
            }
            else if (!IsVariable && otherSfv.IsVariable)
            {
                SimpleFeatureValue binding;
                if (varBindings.TryGetValue(otherSfv.VariableName, out binding))
                {
                    ExceptWith(false, binding, !otherSfv.Agree);
                }
            }
            else
            {
                SimpleFeatureValue binding;
                if (varBindings.TryGetValue(VariableName, out binding))
                {
                    UnionWith(false, binding, !Agree);
                    SimpleFeatureValue otherBinding;
                    if (varBindings.TryGetValue(otherSfv.VariableName, out otherBinding))
                    {
                        ExceptWith(false, otherSfv, false);
                    }
                    VariableName = null;
                }
                else if (!varBindings.ContainsVariable(otherSfv.VariableName))
                {
                    return(VariableName != otherSfv.VariableName || Agree != otherSfv.Agree);
                }
            }

            return(IsSatisfiable);
        }