当前位置: 首页>>代码示例>>C#>>正文


C# Line.GetPrev方法代码示例

本文整理汇总了C#中Line.GetPrev方法的典型用法代码示例。如果您正苦于以下问题:C# Line.GetPrev方法的具体用法?C# Line.GetPrev怎么用?C# Line.GetPrev使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Line的用法示例。


在下文中一共展示了Line.GetPrev方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AbsorbAnyBlanks

        /***************************************************************************
         * Function: AbsorbAnyBlanks
         * Purpose:
         * Update PLINE by making it point to the first non-blank
         * at-or-after from but not after limit.
         * If they are all blank then make it point to limit
         * If from is non-blank then leave it alone.
         * Return true iff PLINE was updated.
         * It is legit for limit to be null (meaning end of file).*/
        public static bool AbsorbAnyBlanks(ref Line from , Line limit, bool bMoveToNext )
        {
            bool progress = false;

            while ( ( from != null ) && ( from.IsBlank() ) && ( from != limit ) ) {
                if( bMoveToNext ) from = (Line)from.GetNext();
                else			  from = (Line)from.GetPrev();
                progress = true;
            }
            return progress;
        }
开发者ID:otodo,项目名称:Diffbycs,代码行数:20,代码来源:Section.cs

示例2: ExpandAnchor

        /***************************************************************************
         * Function: ExpandAnchor
         * Purpose:
         * Given an anchor point (two lines that we think should match),
         * try to link them, and the lines above and below them for as long
         * as the lines can be linked (are the same, are unlinked).
         * Return true if we make any links.  */
        public static bool ExpandAnchor(Section sec1, Line line1, Section sec2, Line line2,bool isIgnoreBlanks)
        {
            /* when a line is matched we set bChanges.	If we notice some
             * blank lines, but do NOT link any new non-blank lines, we
             * do NOT set bChanges.	 (If we did it would cause a closed
             * loop as they would get noticed again next time.	line_link
             * only returns true if it is a NEW link).
             * At this stage we are only interested in making links, not in
             * the size of the section that results (that fun comes later).
             * therefore trailing blanks at the end of a section are not
             * interesting and we don't look for them. */
            bool bChanges = false;

            /* We handle the section limits by using a sentinel which is one
             * past the end of the section.	 (If the section ends at the end
             * of the list then the sentinel is null). */
            Line leftend  = (Line)sec1.last.GetNext();
            Line rightend = (Line)sec2.last.GetNext();

            /* null lines shall not match */
            if ((line1 == null) || (line2 == null)) return false;

            /* check all lines forward until fail to link (because null,
             * not matching, or already linked). include the passed in anchor point since this has not
             * yet been linked. If blanks are ignorable then skip over any number of whole
             * blank lines. */
            Line left  = line1;
            Line right = line2;
            for(;;){
                if( left.Link( right, isIgnoreBlanks ) ){
                    bChanges = true;
                    left  = (Line)left.GetNext();
                    right = (Line)right.GetNext();
                    if( left == leftend || right == rightend ) break;
                }
                else if( isIgnoreBlanks ){
                    /* even though no match, maybe an ignorable blank? */
                    bool moved = false;
                    moved |= AbsorbAnyBlanks( ref left,  leftend, /*bMoveToNext=*/true);
                    moved |= AbsorbAnyBlanks( ref right, rightend,/*bMoveToNext=*/true);
                    if( !moved ) break; /* it didn't match and we didn't move on */
                    if( left == leftend || right == rightend ) break;
                }
                else break;
            }

            /* check all matches going backwards from anchor point
               but only if it was a real anchor	 (could have been
               end-of-section/end-of-file and non-matching). */
            if( line1.link == null ) return bChanges;

            left  = (Line)line1.GetPrev();
            right = (Line)line2.GetPrev();
            if( left == null || right == null ) return bChanges;

            leftend	 = (Line)sec1.first.GetPrev();
            rightend = (Line)sec2.first.GetPrev();

            for(;;){
                if( left.Link(right,isIgnoreBlanks) ){
                    bChanges = true;
                    left  = (Line)left.GetPrev();
                    right = (Line)right.GetPrev();
                    if( left == leftend || right == rightend ) break;
                }
                else if( isIgnoreBlanks ){
                    /* even though no match, maybe an ignorable blank? */
                    bool moved = false;
                    moved |= AbsorbAnyBlanks( ref left,  leftend, /*bMoveToNext=*/false);
                    moved |= AbsorbAnyBlanks( ref right, rightend, /*bMoveToNext=*/false);
                    if( !moved ) break; /* it didn't match and we didn't move on */
                    if( left == leftend || right == rightend ) break;
                }
                else break;
            }

            return bChanges;
        }
开发者ID:otodo,项目名称:Diffbycs,代码行数:85,代码来源:Section.cs


注:本文中的Line.GetPrev方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。