コード例 #1
0
        private static List <List <string> > Intersect(List <List <string> > a, List <List <string> > b)
        {
            if (IsAny(a))
            {
                return(b);
            }
            if (IsAny(b))
            {
                return(a);
            }
            var cmp = new LXComporer();
            var ret = new List <List <string> >();

            foreach (List <string> k in a)
            {
                foreach (List <string> l in b)
                {
                    var inter = new List <string>();
                    foreach (string x in l)
                    {
                        if (k.BinarySearch(x) < 0)
                        {
                            inter.Add(x);
                        }
                    }
                    inter.AddRange(k);
                    inter.Sort();
                    if (ret.BinarySearch(inter, cmp) < 0)
                    {
                        ret.Add(inter);
                    }
                }
            }
            ret.Sort(cmp);
            return(ret);
        }
コード例 #2
0
        private static List <List <string> > Cumulate(List <List <string> > a, List <List <string> > b)
        {
            if (IsAny(a))
            {
                return(a);
            }
            if (IsAny(b))
            {
                return(b);
            }
            var cmp = new LXComporer();
            var ret = new List <List <string> >();

            foreach (List <string> l in b)
            {
                if (a.BinarySearch(l, cmp) < 0)
                {
                    ret.Add(l);
                }
            }
            ret.AddRange(a);
            ret.Sort(cmp);
            return(ret);
        }