示例#1
0
        TPredicatePathNode FillPathNode(TPredicateItemBig AHead, TDynamicArray ADyn)
        {
            int  m_who;
            bool valid = false;
            TPredicateItemBase Item;
            TPredicatePathNode N = null;
            TDynamicArray      D = new TDynamicArray();

            for (int i = 0; i <= ADyn.Count - 1; i++)
            {
                Item  = (TPredicateItemBase)(ADyn.GetItems(i));
                m_who = Item.Who();
                valid = m_who == 0;
                if (m_who == 1)
                {
                    valid = ((TPredicateItemBig)(Item)).ValidDescendant();
                }
                if (valid)
                {
                    D.Append(Item);
                }
            }

            if (D.Count > 0)
            {
                N = f_BasePath.CreatePathNode(AHead);
                for (int i = 0; i <= D.Count - 1; i++)
                {
                    N.AddItem((TPredicateItemBase)(D.GetItems(i)));
                }
            }
            D = null;
            return(N);
        }
示例#2
0
        public void GetTreeListTFSFromBasis(TAlternateTreeList Alternative,
                                            TDynamicArray D, ref bool AValid)
        {
            TBaseWorkShape NS, NE, CR;
            TTreeListTFS   Tmp;
            bool           f = false;
            bool           e = false;

            NS = Alternative.NodeStart.WorkShape;
            NE = Alternative.NodeEnd.WorkShape;
            for (int i = 0; i <= BasisCount - 1; i++)
            {
                Tmp = GetBasisItems(i);
                CR  = Tmp.BaseWorkShape;
                if (!f && (CR == NS))
                {
                    f = true;
                }

                if (f && !e)
                {
                    D.Append(Tmp);
                }

                if (!e && (CR == NE))
                {
                    e = true;
                }
            }
            AValid = f && e;
        }
示例#3
0
        void SetPathNode(TPredicateItemBig AHead, TDynamicArray ADyn)
        {
            int mpos = -1;
            TPredicatePathNode     L;
            TPredicatePathNodeItem NI;
            TPredicatePathNodeItem FI;
            TDynamicArray          D = new TDynamicArray();
            TPredicatePathNode     N = FillPathNode(AHead, ADyn);

            if (N != null)
            {
                L = f_UsedPath.FindLikePathNode(N);
                if (L != null)
                {
                    NI = L.FindIndexFirst(ref mpos);
                    while (NI != null)
                    {
                        FI = N.FindByBlockID(NI.BlockID);
                        if (FI != null)
                        {
                            D.Append(FI.ItemBase);
                        }
                        NI = L.FindIndexNext(ref mpos);
                    }
                }
            }
            if (D.Count == ADyn.Count)
            {
                ADyn.Clear();
                SharedConst.CopyDynamicArray(D, ADyn, false);
            }
            D = null;
        }
示例#4
0
        public TPredicateTreeItem FindByTfeID(int AID, TDynamicArray Arr)
        {
            TPredicateTreeItem Item, Res = null;

            if (Arr != null)
            {
                Arr.Clear();
            }
            for (int i = 0; i <= Count - 1; i++)
            {
                Item = GetItems(i);
                for (int j = 0; j <= Item.Count - 1; j++)
                {
                    if (Item.GetTFE_ID(j) == AID)
                    {
                        if (Res == null)
                        {
                            Res = Item;
                        }
                        if (Arr != null)
                        {
                            Arr.Append(Item);
                        }
                    }
                }
            }
            return(Res);
        }
示例#5
0
        public void ArrayIDToDelete(TPredicateTreeItem AItem, ref TDynamicArray Arr)
        {
            TPredicateTreeItem Item;

            Arr.Clear();
            int del, cfind;

            for (int i = 0; i <= AItem.Count - 1; i++)
            {
                del   = AItem.GetTFE_ID(i);
                cfind = 0;
                for (int j = 0; j <= f_List.Count - 1; j++)
                {
                    Item = (TPredicateTreeItem)(f_List.ElementAt(j));
                    if (!Item.TReated && (Item != AItem))
                    {
                        for (int k = 0; k <= Item.Count - 1; k++)
                        {
                            if (del == Item.GetTFE_ID(k))
                            {
                                cfind++;
                            }
                        }
                    }
                }
                if (cfind == 0 && Arr.Find(del) == null)
                {
                    Arr.Append(del);
                }
            }
        }
        void DoEnlarge()
        {
            int m, cnt, index, r_f, r_pos, m_id;
            TAlternativeParserEnlargerStep MStep;
            TAlternativeParserEnlargerItem A, B;
            TDynamicArray DM = new TDynamicArray();

            MStep = new TAlternativeParserEnlargerStep();
            int  c_trash;
            bool go = true;

            while (go)
            {
                go      = false;
                m       = FindMax().Count;
                cnt     = Count;
                c_trash = 0;
                for (int i = m; i >= 1; i--)
                {
                    DM.Clear();
                    for (int j = 0; j <= cnt - 1; j++)
                    {
                        A = GetItems(j);
                        MStep.Clear();
                        index = 0;
                        r_f   = A.FillStep(MStep, index, i);
                        DM.Append(A);
                        while (r_f > 0)
                        {
                            m_id = SharedConst.NextTrashItemID();
                            for (int k = 0; k <= cnt - 1; k++)
                            {
                                B = GetItems(k);
                                if (DM.Find(B) == null)
                                {
                                    r_pos = B.Pos(MStep);
                                    if (r_pos >= 0)
                                    {
                                        CreateTrashItem(A.GetItems(index), i, A, m_id);
                                        CreateTrashItem(B.GetItems(r_pos), i, B, m_id);
                                        c_trash++;
                                    }
                                }
                            }
                            MStep.Clear();
                            r_f = A.FillStep(MStep, ++index, i);
                        }
                    }
                    if (c_trash > 0)
                    {
                        Restruct();
                        go = true;
                        break;
                    }
                }
            }
            MStep = null;
            DM    = null;
        }
示例#7
0
 /*     public  bool GetAlternateInfo(int AShapeID, int &AltID, int &NumAlt, int &IDParent);*/
 public void GetAllWorkShape(TDynamicArray AMass)
 {
     if (AMass != null)
     {
         AMass.Clear();
         for (int i = 0; i <= MainList.Count - 1; i++)
         {
             AMass.Append(((TNodeMain)(MainList.ElementAt(i))).WorkShape);
         }
     }
 }
示例#8
0
 void BasisAdd(TTreeListTFS ATFS)
 {
     for (int i = 0; i <= f_Basis.Count - 1; i++)
     {
         if (f_Basis.GetItems(i) == ATFS)
         {
             return;
         }
     }
     f_Basis.Append(ATFS);
 }
示例#9
0
        TMainTreeList FindByLevel(TMainTreeList ABegin, int ALevel)
        {
            TMainTreeList Res = null;
            TDynamicArray Dyn = new TDynamicArray();

            Dyn.Append(ABegin);
            int q = 0;

            while (Dyn.GetItems(q) != null)
            {
                Res = (TMainTreeList)(Dyn.GetItems(q));
                for (int i = 0; i <= Res.ItemCount - 1; i++)
                {
                    for (int j = 0; j <= Res.GetAlternateItem(i).ItemCount - 1; j++)
                    {
                        for (int k = 0; k <= Res.GetAlternateItem(i).GetTreeTFSItem(j).ItemCount - 1; k++)
                        {
                            if (Res.GetAlternateItem(i).GetTreeTFSItem(j).GetTreeTFEItem(k).MainNode != null)
                            {
                                Dyn.Append(Res.GetAlternateItem(i).GetTreeTFSItem(j).GetTreeTFEItem(k).MainNode);
                            }
                        }
                    }
                }
                q++;
            }


            for (int i = 0; i <= Dyn.Count - 1; i++)
            {
                Res = (TMainTreeList)(Dyn.GetItems(i));
                if (Res.Level == ALevel)
                {
                    Dyn.Clear();
                    return(Res);
                }
            }
            Dyn.Clear();
            return(null);
        }
        public void FindTrashItem(TAlternativeParserGrpCrossItem AOwner, TDynamicArray AOut)
        {
            TAlternativeParserEnlargerTrashItem Item;

            AOut.Clear();
            for (int i = 0; i <= f_Trash.Count - 1; i++)
            {
                Item = f_Trash.GetItems(i);
                if (Item.Owner.ParentMain == AOwner)
                {
                    AOut.Append(Item);
                }
            }
        }
示例#11
0
 public static void CopyDynamicArray(TDynamicArray ASource, TDynamicArray ADest, bool AInsertToFirst)
 {
     for (int i = 0; i <= ASource.Count - 1; i++)
     {
         if (AInsertToFirst)
         {
             ADest.InsertToFirst(ASource.GetItems(i));
         }
         else
         {
             ADest.Append(ASource.GetItems(i));
         }
     }
 }
示例#12
0
        /*         TTreeListItem* FindTFE(TBaseShape* ABaseShape);*/
        public void FindAlternate(TBaseWorkShape ABaseWorkShape, TDynamicArray D)
        {
            TBaseWorkShape Tfs;

            D.Clear();
            for (int i = 0; i <= ItemCount - 1; i++)
            {
                Tfs = GetAlternateItem(i).NodeStart.WorkShape;
                if (Tfs == ABaseWorkShape)
                {
                    D.Append(GetAlternateItem(i));
                }
            }
        }
示例#13
0
        void CheckTFS()
        {
            TAlternativeParserGrpItemTFS  Temp;
            TAlternativeParserGrpItemBase Item;
            TAlternativeParserGrpItemList List;
            TDynamicArray mTfs = new TDynamicArray();
            TDynamicArray mGrp = new TDynamicArray();
            TDynamicArray mDbl = new TDynamicArray();

            for (int i = 0; i <= f_List.Count - 1; i++)
            {
                Item = (TAlternativeParserGrpItemBase)(f_List.ElementAt(i));
                int m_who = Item.Who();
                if (m_who <= 0)
                {
                    mTfs.Append(Item);
                }
                if (m_who == 1)
                {
                    mGrp.Append(Item);
                }
            }
            for (int i = 0; i <= mTfs.Count - 1; i++)
            {
                Item = (TAlternativeParserGrpItemBase)(mTfs.GetItems(i));
                Temp = (TAlternativeParserGrpItemTFS)(Item);
                for (int j = 0; j <= mGrp.Count - 1; j++)
                {
                    Item = (TAlternativeParserGrpItemBase)(mGrp.GetItems(j));
                    List = (TAlternativeParserGrpItemList)(Item);
                    if (List.FindItemTfs(Temp.TFS) != null)
                    {
                        mDbl.Append(Temp);
                    }
                }
            }
            for (int i = 0; i <= mDbl.Count - 1; i++)
            {
                Item = (TAlternativeParserGrpItemBase)(mDbl.GetItems(i));
                FreeItem(Item);
            }
            mDbl = null;
            mGrp = null;
            mTfs = null;
        }
        public void Restruct()
        {
            int mpos;
            TAlternativeParserEnlargerTrashItem TI;
            TDynamicArray mDel = new TDynamicArray();

            for (int i = 0; i <= f_Trash.Count - 1; i++)
            {
                TI   = f_Trash.GetItems(i);
                mpos = TI.Owner.Find(TI.Pos);
                if (mpos >= 0)
                {
                    mDel.Clear();
                    for (int j = mpos; j <= mpos + TI.Length - 1; j++)
                    {
                        mDel.Append(TI.Owner.GetItems(j));
                    }
                    TI.Owner.CascadeDelete(mDel);
                }
            }
            mDel = null;
        }
示例#15
0
        void CheckList()
        {
            TAlternativeParserGrpItemBase Item;
            TAlternativeParserGrpItemList List1, List2;
            TDynamicArray mList = new TDynamicArray();
            TDynamicArray mDbl  = new TDynamicArray();

            for (int i = 0; i <= f_List.Count - 1; i++)
            {
                Item = (TAlternativeParserGrpItemBase)(f_List.ElementAt(i));
                if (Item.Who() == 1)
                {
                    mList.Append(Item);
                }
            }

            for (int i = 0; i <= mList.Count - 1; i++)
            {
                Item  = (TAlternativeParserGrpItemBase)(mList.GetItems(i));
                List1 = (TAlternativeParserGrpItemList)(Item);
                for (int j = i + 1; j <= mList.Count - 1; j++)
                {
                    Item  = (TAlternativeParserGrpItemBase)(mList.GetItems(j));
                    List2 = (TAlternativeParserGrpItemList)(Item);
                    if (IdentityAlternate(List1, List2))
                    {
                        mDbl.Append(Item);
                    }
                }
            }
            for (int i = 0; i <= mDbl.Count - 1; i++)
            {
                Item = (TAlternativeParserGrpItemBase)(mDbl.GetItems(i));
                FreeItem(Item);
            }
            mDbl  = null;
            mList = null;
        }
示例#16
0
        void FindAlternate2(TBaseWorkShape AFirstWorkShape, TBaseWorkShape AEndWorkShape, TDynamicArray D)
        {
            TBaseWorkShape Tfs1, Tfs2;

            D.Clear();
            for (int i = 0; i <= ItemCount - 1; i++)
            {
                Tfs1 = null;
                Tfs2 = null;
                if (GetAlternateItem(i).NodeStart != null)
                {
                    Tfs1 = GetAlternateItem(i).NodeStart.WorkShape;
                }
                if (GetAlternateItem(i).NodeEnd != null)
                {
                    Tfs2 = GetAlternateItem(i).NodeEnd.WorkShape;
                }
                if ((Tfs1 == AFirstWorkShape) && (Tfs2 == AEndWorkShape))
                {
                    D.Append(GetAlternateItem(i));
                }
            }
        }
示例#17
0
        void MakeOUT()
        {
            TAlternativeParserGrpItemList Temp;
            TAlternativeParserGrpItemBase Item;
            TDynamicArray D = new TDynamicArray();

            for (int i = 0; i <= f_List.Count - 1; i++)
            {
                Item = (TAlternativeParserGrpItemBase)(f_List.ElementAt(i));
                int m_who = Item.Who();
                if (m_who <= 0)
                {
                    f_ListOut.Add(Item);
                }
                if (m_who == 1)
                {
                    Temp = (TAlternativeParserGrpItemList)(Item);
                    Item = CheckOut(Temp);
                    if (Item != null)
                    {
                        if (D.Find(Item) == null)
                        {
                            D.Append(Item);
                            f_ListOut.Add(Item);
                            if (Item.Who() == 2)
                            {
                                TAlternativeParserGrpCrossItem iTmp = (TAlternativeParserGrpCrossItem)(Item);
                                iTmp.CreateBasis();
                                iTmp.CreateListOut();
                            }
                        }
                    }
                }
            }
            D = null;
        }
示例#18
0
        void DoProcessItem(TPredicateItemBig AHead, TDynamicArray AStack)
        {
            int m_type, m_cnt, m_idx;
            TPredicateItemBase  m_Base;
            TPredicateItemBase  m_BaseItem1, m_BaseItem2;
            TPredicateItemPWork m_PWork, m_PW;
            TPredicateItemBig   m_Big;
            TPredicateItemTFS   m_Tfs;
            TPredicateItemTFE   m_Tfe;
            TDynamicArray       m_D     = new TDynamicArray();
            TDynamicArray       m_DTail = new TDynamicArray();
            TDynamicArray       m_DLN   = new TDynamicArray();

            m_cnt = AHead.Count;
            if (m_cnt == 1)
            {
                m_Base = AHead.GetItems(0);
                DoProcessItemTFS(m_Base, AStack);
                if (m_Base.Who() == 1)
                {
                    ((TPredicateItemBig)(m_Base)).Print = true;
                }

                ApplyStyle(AHead, m_Base);
            }
            if (m_cnt > 1)
            {
                for (int i = 0; i <= m_cnt - 1; i++)
                {
                    m_Base = AHead.GetItems(i);
                    m_type = m_Base.Who();
                    if (m_type == 1)
                    {
                        m_Big = (TPredicateItemBig)(m_Base);
                        if (m_Big.NumAlt > 0 || m_Big.Rfc.Cross)
                        {
                            m_DTail.Append(m_Big);
                            m_Big.Print = true;
                        }
                        else
                        {
                            m_DLN.Append(m_Base);
                            // m_Big.Print = m_Big.Rfc.CrossMain;
                        }
                    }
                    else
                    {
                        m_DLN.Append(m_Base);
                    }
                }
                if (m_DLN.Count == 1)
                {
                    m_Base = (TPredicateItemBase)(m_DLN.GetItems(0));
                    DoProcessItemTFS(m_Base, AStack);
                    ApplyStyle(AHead, m_Base);
                }
                else
                if (m_DLN.Count > 1)
                {
                    ApplyStyle(AHead, m_DLN);
                    m_BaseItem1 = (TPredicateItemBase)(m_DLN.GetItems(0));
                    m_BaseItem2 = (TPredicateItemBase)(m_DLN.GetItems(1));
                    DoProcessItemTFS(m_BaseItem1, AStack);
                    DoProcessItemTFS(m_BaseItem2, AStack);
                    for (int i = 2; i <= m_DLN.Count - 1; i++)
                    {
                        m_D.Append(m_DLN.GetItems(i));
                    }

                    AHead.DeleteItemToList(m_BaseItem1);
                    AHead.DeleteItemToList(m_BaseItem2);


                    m_BaseItem1 = EnvelopeToBig(m_BaseItem1);
                    m_BaseItem2 = EnvelopeToBig(m_BaseItem2);

                    m_PWork       = new TPredicateItemPWork();
                    m_PWork.Item1 = m_BaseItem1;
                    m_PWork.Item2 = m_BaseItem2;
                    SwapNumAlt(m_PWork, m_BaseItem1);



                    while (m_D.Count >= 1)
                    {
                        m_Big = (TPredicateItemBig)(EnvelopeToBig(m_PWork));

                        m_BaseItem1 = m_Big;
                        m_BaseItem2 = (TPredicateItemBase)(m_D.GetItems(0));
                        DoProcessItemTFS(m_BaseItem2, AStack);
                        AHead.DeleteItemToList(m_BaseItem2);

                        m_PW = new TPredicateItemPWork();
                        //m_PW.Envelope = true;
                        m_PW.Item1 = m_BaseItem1;
                        m_PW.Item2 = EnvelopeToBig(m_BaseItem2);
                        SwapNumAlt(m_PW, m_Big);
                        m_D.Delete(m_BaseItem2);
                        m_PWork = m_PW;
                    }

                    AHead.AddItem(m_PWork);
                }

                for (int i = 0; i <= m_DTail.Count - 1; i++)
                {
                    m_Base = (TPredicateItemBase)(m_DTail.GetItems(i));
                    AStack.InsertToFirst(m_Base);
                }

                m_DTail = null;
                m_DLN   = null;
                m_D     = null;
            }
        }