示例#1
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));
         }
     }
 }
 public void CascadeDelete(TDynamicArray AMass)
 {
     for (int i = 0; i <= AMass.Count - 1; i++)
     {
         DeleteTfsItem((TAlternativeParserGrpItemTFS)(AMass.GetItems(i)));
     }
 }
示例#3
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);
        }
示例#4
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);
        }
示例#5
0
        void CreateParserGrpItemList(TDynamicArray AMass, TAlternateTreeList Alternative)
        {
            TAlternativeParserGrpItemList Item;

            if (AMass.Count > 0)
            {
                Item = f_Grp.GetNewList(Alternative);
                for (int i = 0; i <= AMass.Count - 1; i++)
                {
                    Item.AddTfs((TTreeListTFS)(AMass.GetItems(i)));
                }
            }
        }
示例#6
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;
        }
示例#7
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;
        }
示例#8
0
        public bool CompareBasisAndMassiv(TDynamicArray AMass)
        {
            int LenB = BasisCount;
            int LenA = AMass.Count;

            if (LenA != LenB)
            {
                return(false);
            }
            for (int i = 0; i <= LenA - 1; i++)
            {
                if (GetBasisItems(i) != AMass.GetItems(i))
                {
                    return(false);
                }
            }
            return(true);
        }
示例#9
0
        void RestructEnlarge(TAlternativeParserGrpCrossItem AItem)
        {
            TAlternativeParserGrpItemTFS          mPos;
            TAlternativeParserGrpCrossItemEnlarge Enl;
            TAlternativeParserEnlargerTrashItem   TrItem;
            TDynamicArray Mass = new TDynamicArray();

            f_Enlarger.FindTrashItem(AItem, Mass);
            for (int i = 0; i <= Mass.Count - 1; i++)
            {
                TrItem = (TAlternativeParserEnlargerTrashItem)(Mass.GetItems(i));
                Enl    = AItem.FindEnlarge(TrItem.Pos);
                if (Enl == null)
                {
                    AddToListEnlarge(AItem.RestructEnlarge(TrItem));
                }
            }
            Mass = null;
        }
示例#10
0
        public void InitData()
        {
            TBaseWorkShape WS;
            TBaseShape     TFE;
            TGlsBinaryTree BTree = new TGlsBinaryTree(OPM_CompareNode);

            for (int i = 0; i <= MassWork.Count - 1; i++)
            {
                WS = (TBaseWorkShape)(MassWork.GetItems(i));
                for (int j = 0; j <= WS.WorkShapesCount - 1; j++)
                {
                    TFE = (TBaseShape)(WS.GetWorkShape(j));
                    BTree.insert(TFE);
                }
            }

            MassWork.Clear();
            BTree.inorder(OPM_Inorder);
            //   delete BTree;
            CheckCol();
        }
示例#11
0
        void MakeBig(ref TAlternativeParserItemBig ABig, bool AByPass)
        {
            int                       m_n = 0;
            bool                      b_basis, b_main, b_tail, b_go, b_parent, b_cbm, b_valid = false;
            TTreeListTFS              TFS;
            TAlternateTreeList        AItem;
            TAlternativeParserItemBig NewBig;
            TMainTreeList             m_Tree = ABig.MainTreeList;

            TDynamicArray D      = new TDynamicArray();
            TDynamicArray Mass   = new TDynamicArray();
            bool          m_whl  = true;
            bool          m_hook = false;

            while (m_whl)
            {
                m_whl = false;
                f_Grp.Clear();
                for (int i = 0; i <= ABig.BasisCount - 1; i++)
                {
                    TFS = ABig.GetBasisItems(i);
                    m_Tree.FindAlternate(TFS.BaseWorkShape, D);
                    b_go = false;
                    if (D.Count > 0)
                    {
                        for (int j = 0; j <= D.Count - 1; j++)
                        {
                            AItem    = (TAlternateTreeList)(D.GetItems(j));
                            b_basis  = ABig.CompareBasisAndAlternateTreeList(AItem);
                            b_main   = AItem.MainAlternative;
                            b_tail   = ABig.IsTailAlternateTreeList(AItem);
                            b_parent = ABig.ParentTFE != null;
                            if (!b_basis && !b_main)
                            {
                                Mass.Clear();
                                ABig.GetTreeListTFSFromBasis(AItem, Mass, ref b_valid);
                                if (!b_valid)
                                {
                                    continue;
                                }
                                b_cbm = ABig.CompareBasisAndMassiv(Mass);
                                b_go  = (AByPass || !b_cbm || b_parent);
                                if (b_go)
                                {
                                    CreateParserGrpItemList(Mass, AItem);
                                }
                            }
                            if (b_tail && !b_main && !b_go)
                            {
                                m_n++;
                                NewBig        = new TAlternativeParserItemBig();
                                NewBig.NumAlt = m_n;
                                NewBig.FillBasisAlternateTreeList(AItem);
                                NewBig.OwnerBig = ABig;
                                ABig.AddBig(NewBig);
                            }
                        }
                    }
                    f_Grp.AddTfs(TFS);
                }

                if (ABig.BadBasis && !m_hook)
                {
                    ABig.HookBasisBig();
                    m_hook = true;
                    m_whl  = true;
                }
            }
            f_Grp.Make();
            FillBigFromGrp(ref ABig);
            D    = null;
            Mass = null;
        }
示例#12
0
 public TTreeListTFS GetBasisItems(int AIndex)
 {
     return((TTreeListTFS)(f_Basis.GetItems(AIndex)));
 }
示例#13
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;
            }
        }