Beispiel #1
0
        public virtual int compareTo(GraphElement o)
        {
            const int BEFORE = -1;
            const int EQUAL  = 0;
            const int AFTER  = 1;

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

            if (labelSet == null && o.labelSet != null)
            {
                return(BEFORE);
            }
            if (labelSet != null && o.labelSet == null)
            {
                return(AFTER);
            }
            if (labelSet == null && o.labelSet == null)
            {
                return(EQUAL);
            }

            int comparison = EQUAL;

            foreach (SymbolTable table in labelSet.Keys)
            {
                int?ocode = o.labelSet.get(table);
                int?tcode = labelSet.get(table);
                if (ocode != null && tcode != null)
                {
                    if (!ocode.Equals(tcode))
                    {
                        try
                        {
                            comparison = table.getSymbolCodeToString(tcode.Value).CompareTo(table.getSymbolCodeToString(ocode.Value));
                            if (comparison != EQUAL)
                            {
                                return(comparison);
                            }
                        }
                        catch (MaltChainedException)
                        {
                        }
                    }
                }
            }
            return(EQUAL);
        }
Beispiel #2
0
        public override bool Equals(object obj)
        {
            GraphElement ge = (GraphElement)obj;

            return(belongsToGraph == ge.BelongsToGraph && labelSet == null ? ge.LabelSet == null : labelSet.Equals(ge.LabelSet));
        }