本文整理汇总了C#中System.Collections.BitArray.FirstTrueIndex方法的典型用法代码示例。如果您正苦于以下问题:C# BitArray.FirstTrueIndex方法的具体用法?C# BitArray.FirstTrueIndex怎么用?C# BitArray.FirstTrueIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.BitArray
的用法示例。
在下文中一共展示了BitArray.FirstTrueIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: colorFunction
private List<int> colorFunction(FunctionBlock<SparcInstruction> f)
{
var uncolorableRegs = new List<int>();
var dg = allDepGraphs[f];
var map = colorMapping[f.Name];
var stack = new Stack<NodeAndEdges>(numRegs);
var notConstrained = Enumerable.Range(0, numRegs).Where(r => !isConstrained(r, dg[r])).ToList();
var constrained = Enumerable.Range(0, numRegs).Where(r => isConstrained(r, dg[r])).ToList();
var constrainedAndUncolorable = new List<int>(constrained);
//Push all unconstrained nodes first
foreach (var r in notConstrained)
{
var bits = dg[r];
stack.Push(new NodeAndEdges() { Reg = r, Edges = new BitArray(bits) });
removeEdges(dg, r, bits);
}
//Console.WriteLine("\t{0}:{1} reg constr", f.Name, constrained.Count);
//While there still exists constrained registers
while (constrained.Count != 0)
{
var constrainedNdx = constrained.MaxIndex(r => dg[r].NumberOfBitsSet());
var reg = constrained[constrainedNdx];
var bits = dg[reg];
stack.Push(new NodeAndEdges() { Reg = reg, Edges = new BitArray(bits) });
removeEdges(dg, reg, bits);
constrained.Remove(reg);
}
while (stack.Count != 0)
{
var val = stack.Pop();
var bits = val.Edges;
SparcRegister reg = getSparcRegister(val.Reg);
if (reg == null)
{
var cans = new BitArray(candidateColors);
for (int i = 0; i < bits.Length; i++)
{
if (bits[i])
cans[map[i].IntVal] = false;
}
reg = virtToSparc[cans.FirstTrueIndex()];
}
if (reg == null)
{
break;
}
constrainedAndUncolorable.Remove(val.Reg);
map[val.Reg] = reg;
addEdges(dg, val.Reg, bits);
}
constrainedAndUncolorable.Sort((r1, r2) => compareConstrainedness(dg, r1, r2));
return constrainedAndUncolorable;
}