コード例 #1
0
        public override bool Equals(object o)
        {
            if (o == null)
            {
                return(false);
            }

            if (o == this)
            {
                return(true);
            }

            if (o.GetType() == typeof(Structure))
            {
                Structure oAsStructure = (Structure)o;
                if (oAsStructure.IsVar())
                {
                    return(((VarTerm)o).Equals(this));
                }
                int ts = GetArity();
                if (ts != oAsStructure.GetArity())
                {
                    return(false);
                }
                if (!GetFunctor().Equals(oAsStructure.GetFunctor()))
                {
                    return(false);
                }
                if (!GetNS().Equals(oAsStructure.GetNS()))
                {
                    return(false);
                }
                for (int i = 0; i < ts; i++)
                {
                    if (!GetTerm(i).Equals(oAsStructure.GetTerm(i)))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            if (o.GetType() == typeof(Atom) && this.IsAtom())
            {
                return(base.Equals(o));
            }
            return(false);
        }
コード例 #2
0
 public override bool Subsumes(ITerm t)
 {
     if (t.IsStructure())
     {
         Structure s  = (Structure)t;
         int       ma = GetArity();
         int       oa = s.GetArity();
         for (int i = 0; i < ma && i < oa; i++)
         {
             if (!GetTerm(i).Subsumes(s.GetTerm(i)))
             {
                 return(false);
             }
         }
         return(true);
     }
     else
     {
         return(base.Subsumes(t));
     }
 }
コード例 #3
0
        public override int CompareTo(ITerm t)
        {
            int c = base.CompareTo(t);

            if (c != 0)
            {
                return(c);
            }
            if (t.IsStructure())
            {
                Structure s  = (Structure)t;
                int       ma = GetArity();
                int       oa = s.GetArity();
                for (int i = 0; i < ma && i < oa; i++)
                {
                    c = GetTerm(i).CompareTo(s.GetTerm(i));
                    if (c != 0)
                    {
                        return(c);
                    }
                }
            }
            return(c);
        }