本文整理汇总了C#中NodeList.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# NodeList.Skip方法的具体用法?C# NodeList.Skip怎么用?C# NodeList.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeList
的用法示例。
在下文中一共展示了NodeList.Skip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Permute
/// <summary>
/// Flattens a list of nodes seperated by comma so that all the conditions are on the bottom.
/// e.g.
/// (A) and (B) and (C) => A and B and C
/// (A, B) and (D) and (C) => A and D and C, B and D and C
/// (A) and (B) and (C, D) => A and B and C, A and B and D
///
/// It does this by generating a list of permutations for the last n-1 then n-2
/// and with each call it multiplies out the OR'd elements
/// </summary>
private NodeList Permute(NodeList<NodeList> arr)
{
// in simple cases return
if (arr.Count == 0)
return new NodeList();
if (arr.Count == 1)
{
return arr[0];
}
NodeList returner = new NodeList();
// run permute on the next n-1
NodeList<NodeList> sliced = new NodeList<NodeList>(arr.Skip(1));
NodeList rest = Permute(sliced);
//now multiply
for (int i = 0; i < rest.Count; i++)
{
NodeList inner = arr[0];
for (int j = 0; j < inner.Count; j++)
{
NodeList newl = new NodeList();
newl.Add(inner[j]);
NodeList addition = rest[i] as NodeList;
if (addition)
{
newl.AddRange(addition);
}
else
{
newl.Add(rest[i]);
}
//add an expression so it seperated by spaces
returner.Add(new Expression(newl));
}
}
return returner;
}
示例2: NodeList_ReplaceEumerableExtensions
public void NodeList_ReplaceEumerableExtensions()
{
var firstId = 1001;
var skip = 10;
var take = 15;
var baseList = new NodeList<Node>(Enumerable.Range(firstId, 42));
var skipedList = baseList.Skip(skip);
var takenList = skipedList.Take(take);
var castList = takenList.Cast<ContentType>();
Assert.IsInstanceOfType(skipedList, typeof(NodeList<Node>), "List#1 is not an instance of NodeList<Node> but " + skipedList.GetType().FullName);
Assert.IsInstanceOfType(takenList, typeof(NodeList<Node>), "List#2 is not an instance of NodeList<Node> but " + takenList.GetType().FullName);
Assert.IsInstanceOfType(castList, typeof(NodeList<ContentType>), "List#3 is not an instance of NodeList<Node> but " + castList.GetType().FullName);
Assert.IsTrue(takenList.First().Id == firstId + skip, String.Concat("First id is:", takenList.First().Id, ".Expected: ", firstId + skip));
Assert.IsTrue(takenList.Last().Id == firstId + skip + take - 1, String.Concat("Last id is:", takenList.Last().Id, ".Expected: ", firstId + skip + take - 1));
}