示例#1
0
        //////////////////////////////////////////////////////////////////////////////

        public static Obj Copy(SymBinaryTable[] tables)
        {
            int size = 0;

            for (int i = 0; i < tables.Length; i++)
            {
                size += tables[i].Size();
            }

            if (size == 0)
            {
                return(EmptyRelObj.singleton);
            }

            Obj[] objs1 = new Obj[size];
            Obj[] objs2 = new Obj[size];

            int[] buffer = new int[32];

            int next = 0;

            for (int iT = 0; iT < tables.Length; iT++)
            {
                SymBinaryTable table       = tables[iT];
                OneWayBinTable oneWayTable = table.table;
                SurrObjMapper  mapper      = table.mapper;

                int len = oneWayTable.column.Length;
                for (int iS = 0; iS < len; iS++)
                {
                    int count1 = oneWayTable.Count(iS);
                    if (count1 != 0)
                    {
                        if (count1 > buffer.Length)
                        {
                            buffer = new int[Array.Capacity(buffer.Length, count1)];
                        }
                        Obj obj1    = mapper(iS);
                        int _count1 = oneWayTable.Restrict(iS, buffer);
                        Debug.Assert(_count1 == count1);
                        for (int i = 0; i < count1; i++)
                        {
                            int surr2 = buffer[i];
                            if (iS <= surr2)
                            {
                                objs1[next]   = obj1;
                                objs2[next++] = mapper(surr2);
                            }
                        }
                    }
                }
            }
            Debug.Assert(next == size);

            return(Builder.CreateBinRel(objs1, objs2, size)); //## THIS COULD BE MADE MORE EFFICIENT
        }
示例#2
0
        //////////////////////////////////////////////////////////////////////////////

        public static Obj Copy(BinaryTable[] tables, bool flipped)
        {
            int count = 0;

            for (int i = 0; i < tables.Length; i++)
            {
                count += tables[i].Size();
            }

            if (count == 0)
            {
                return(EmptyRelObj.singleton);
            }

            Obj[] objs1 = new Obj[count];
            Obj[] objs2 = new Obj[count];

            int[] buffer = new int[32];

            int next = 0;

            for (int iT = 0; iT < tables.Length; iT++)
            {
                BinaryTable    table       = tables[iT];
                OneWayBinTable oneWayTable = table.table1;

                SurrObjMapper mapper1 = table.mapper1;
                SurrObjMapper mapper2 = table.mapper2;

                int len = oneWayTable.column.Length;
                for (int iS = 0; iS < len; iS++)
                {
                    int count1 = oneWayTable.Count(iS);
                    if (count1 != 0)
                    {
                        if (count1 > buffer.Length)
                        {
                            buffer = new int[Array.Capacity(buffer.Length, count1)];
                        }
                        Obj obj1    = mapper1(iS);
                        int _count1 = oneWayTable.Restrict(iS, buffer);
                        Debug.Assert(_count1 == count1);
                        for (int i = 0; i < count1; i++)
                        {
                            objs1[next]   = obj1;
                            objs2[next++] = mapper2(buffer[i]);
                        }
                    }
                }
            }
            Debug.Assert(next == count);

            return(Builder.CreateBinRel(flipped ? objs2 : objs1, flipped ? objs1 : objs2)); //## THIS COULD BE MADE MORE EFFICIENT
        }
示例#3
0
        //////////////////////////////////////////////////////////////////////////////

        public void InitReverse(OneWayBinTable source)
        {
            // Debug.Assert(count == 0);

            int len = source.column.Length;

            for (int i = 0; i < len; i++)
            {
                int[] surrs = source.Restrict(i);
                for (int j = 0; j < surrs.Length; j++)
                {
                    Insert(surrs[j], i);
                }
            }
        }