本文整理汇总了C#中Block.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# Block.IndexOf方法的具体用法?C# Block.IndexOf怎么用?C# Block.IndexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block
的用法示例。
在下文中一共展示了Block.IndexOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
InitComplements();
var seq = new List<byte[]>();
var b = new Block { Count = -1 };
Index line = Index.None, start = Index.None, end = Index.None;
using (var r = new BinaryReader(Console.OpenStandardInput())) {
using (var w = Console.OpenStandardOutput()) {
while (b.Read(r) > 0) {
seq.Add(b.Data);
if (line.Pos < 0) line = b.IndexOf(Gt, 0);
while (line.Pos >= 0) {
if (start.Pos < 0) {
var off = line.InBlock(b) ? line.Pos : 0;
start = b.IndexOf(Lf, off);
if (start.Pos < 0) {
w.Write(b.Data, off, b.Data.Length - off);
seq.Clear(); break;
}
w.Write(b.Data, off, start.Pos + 1 - off);
}
if (end.Pos < 0) {
end = b.IndexOf(Gt, start.InBlock(b) ? start.Pos : 0);
if (end.Pos < 0) break;
}
w.Reverse(start.Pos, end.Pos, seq);
if (seq.Count > 1) seq.RemoveRange(0, seq.Count - 1);
line = end; end = Index.None; start = Index.None;
}
}
if (start.Pos >= 0 && end.Pos < 0)
w.Reverse(start.Pos, seq[seq.Count -1].Length, seq);
}
}
}
示例2: PreviousStatementIndex
private static int PreviousStatementIndex(Block node, AstNode child)
{
// get the index of the statement before the last return
// (skip over function decls and importand comments)
var indexPrevious = node.IndexOf(child) - 1;
while (indexPrevious >= 0 && (node[indexPrevious] is FunctionObject || node[indexPrevious] is ImportantComment))
{
--indexPrevious;
}
return indexPrevious;
}