Esempio n. 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);
        }
Esempio n. 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));
     }
 }
Esempio n. 3
0
        public override IListTerm GetSources()
        {
            IListTerm ls = new ListTermImpl();

            if (annotations != null)
            {
                IListTerm tail = ls;
                foreach (ITerm ta in annotations)
                {
                    if (ta.IsStructure())
                    {
                        Structure tas = (Structure)ta;
                        if (tas.GetFunctor().Equals("source"))
                        {
                            tail = tail.Append(tas.GetTerm(0));
                        }
                    }
                }
            }
            return(ls);
        }
Esempio n. 4
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);
        }