本文整理汇总了C#中Card.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# Card.ToArray方法的具体用法?C# Card.ToArray怎么用?C# Card.ToArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Card
的用法示例。
在下文中一共展示了Card.ToArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CombinationsNoRepetitions
public static void CombinationsNoRepetitions(int index, int start, List<Card> remainingCards, int variantCardsCount, List<Card[]> result, Card[] currentCombination)
{
//var arr = new Card[variantCardsCount];
if (index >= variantCardsCount)
{
result.Add(currentCombination);
//currentCombination = new Card[variantCardsCount];
return;
}
else
{
for (int i = start; i < remainingCards.Count; i++)
{
currentCombination[index] = remainingCards[i];
CombinationsNoRepetitions(index + 1, i + 1, remainingCards, variantCardsCount, result, currentCombination.ToArray());
}
}
}
示例2: CombinationsNoRepetitionsIterative
// Source: http://rosettacode.org/wiki/Combinations
// TODO: Just generate card indexes
public static IEnumerable<Card[]> CombinationsNoRepetitionsIterative(List<Card> remainingCards, int variantCardsCount)
{
Card[] result = new Card[variantCardsCount];
Stack<int> stack = new Stack<int>();
stack.Push(0);
while (stack.Count > 0)
{
int index = stack.Count - 1;
int value = stack.Pop();
while (value < remainingCards.Count)
{
result[index++] = remainingCards[value++];
stack.Push(value);
if (index == variantCardsCount)
{
yield return result.ToArray();
break;
}
}
}
}