示例#1
0
        public static int Compare(IGroup x, IGroup y, IComparer comp)
        {
            if (x == null)
            {
                return((y == null) ? 0 : -1);
            }
            if (y == null)
            {
                return(1);
            }
            if (x == y)
            {
                return(0);
            }

            IGroup ox = TopGroup(x, out int xLevel), oy = TopGroup(y, out int yLevel);

            if (ox == oy)
            {
                ox = x; oy = y;
                int oxLevel = xLevel, oyLevel = yLevel;

                while (ox.Group != oy.Group)
                {
                    if (oxLevel > oyLevel)
                    {
                        ox = ox.Group;
                        oxLevel--;
                    }
                    else if (oxLevel < oyLevel)
                    {
                        oy = oy.Group;
                        oyLevel--;
                    }
                    else
                    {
                        ox = ox.Group; oy = oy.Group;
                        oxLevel--; oyLevel--;
                    }
                }
                if (ox == oy)
                {
                    return(xLevel.CompareTo(yLevel));
                }
            }

            return(ListHelper.Compare(ox, oy, comp, true));
        }
示例#2
0
 public static int CompareKey(IInvoker accesor, object x, object key, IComparer comparer)
 {
     return(ListHelper.Compare(accesor.GetValue(x), key, comparer, false));
 }