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


C# Sequence.Length方法代码示例

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


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

示例1: Concat

            /**
             * Creates a new token sequence that is the concatenation
             * of this sequence and another. A maximum length for the
             * new sequence is also specified.
             *
             * @param length         the maximum length of the result
             * @param seq            the other sequence
             *
             * @return the concatenated token sequence
             */
            public Sequence Concat(int length, Sequence seq) {
                Sequence  res = new Sequence(length, this);

                if (seq.repeat) {
                    res.repeat = true;
                }
                length -= this.Length();
                if (length > seq.Length()) {
                    res.tokens.AddRange(seq.tokens);
                } else {
                    for (int i = 0; i < length; i++) {
                        res.tokens.Add(seq.tokens[i]);
                    }
                }
                return res;
            }
开发者ID:netgrim,项目名称:FleeSharp,代码行数:26,代码来源:LookAheadSet.cs

示例2: Sequence

 /**
  * Creates a new token sequence that is a duplicate of
  * another sequence. Only a limited number of tokens will
  * be copied however. The repeat flag from the original
  * will be kept intact.
  *
  * @param length         the maximum number of tokens to copy
  * @param seq            the sequence to copy
  */
 public Sequence(int length, Sequence seq) {
     this.repeat = seq.repeat;
     this.tokens = new ArrayList(length);
     if (seq.Length() < length) {
         length = seq.Length();
     }
     for (int i = 0; i < length; i++) {
         tokens.Add(seq.tokens[i]);
     }
 }
开发者ID:netgrim,项目名称:FleeSharp,代码行数:19,代码来源:LookAheadSet.cs

示例3: StartsWith

 /**
  * Checks if this token sequence starts with the tokens from
  * another sequence. If the other sequence is longer than this
  * sequence, this method will always return false.
  *
  * @param seq            the token sequence to check
  *
  * @return true if this sequence starts with the other, or
  *         false otherwise
  */
 public bool StartsWith(Sequence seq) {
     if (Length() < seq.Length()) {
         return false;
     }
     for (int i = 0; i < seq.tokens.Count; i++) {
         if (!tokens[i].Equals(seq.tokens[i])) {
             return false;
         }
     }
     return true;
 }
开发者ID:netgrim,项目名称:FleeSharp,代码行数:21,代码来源:LookAheadSet.cs

示例4: Add

 /**
  * Adds a token sequence to this set. The sequence will only
  * be added if it is not already in the set. Also, if the
  * sequence is longer than the allowed maximum, a truncated
  * sequence will be added instead.
  *
  * @param seq            the token sequence to add
  */
 private void Add(Sequence seq) {
     if (seq.Length() > maxLength) {
         seq = new Sequence(maxLength, seq);
     }
     if (!Contains(seq)) {
         elements.Add(seq);
     }
 }
开发者ID:netgrim,项目名称:FleeSharp,代码行数:16,代码来源:LookAheadSet.cs


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