本文整理汇总了C#中System.Result.Merge方法的典型用法代码示例。如果您正苦于以下问题:C# Result.Merge方法的具体用法?C# Result.Merge怎么用?C# Result.Merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Result
的用法示例。
在下文中一共展示了Result.Merge方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindSplit
//.........这里部分代码省略.........
bestResult.Cost = initPenalty;
float leftLastScore = initPenalty, rightLastScore = initPenalty;
int leftGrowCount = 0, rightGrowCount = 0;
while (!leftStop || !rightStop)
{
if (!leftStop)
{
// find solution for left and right part
leftTmpResult = FindSplit(dataArray, new Interval(bounds.Left, leftSplit), leftIntervals, optimum, cache);
rightTmpResult = FindSplit(dataArray, new Interval(leftSplit, bounds.Right), intervals - leftIntervals, optimum, cache);
// sum the costs of partial results
float sum = leftTmpResult.Cost + rightTmpResult.Cost;
#if SCOREGRAPH
if (topLevel)
{
// top level in the recursion
Trace.WriteLine(String.Format("{0};{1}", leftSplit, sum));
}
#endif
// first solution is propagated to the right side
if (rightLastScore == initPenalty)
{
// save to right last value
rightLastScore = sum;
}
// compare this result to what we have so far
if (sum < bestResult.Cost)
{
// merge two partial solution to one
bestResult.Merge(leftTmpResult, rightTmpResult);
// absolute stop criterium (perfect result)
if (sum == 0.0f)
break;
}
#if SCOREGRAPH
if (!topLevel)
{
#endif
// check stop criterium (result penalty is too big)
if (sum > stopLimit * bestResult.Cost)
{
// stop spreading to the left
leftStop = true;
}
// check stop criterium (result penalty is constantly growing, so there is
// probably no hope of getting better result than we have...)
if (sum < leftLastScore)
{
// not growing, reset the counter
leftGrowCount = 0;
}
else
{
// growing, increase
leftGrowCount++;
if (leftGrowCount == growLimit)
leftStop = true;
}
示例2: CheckAny
static void CheckAny(Result result, IList<INamedPredicate> predicates, string pathHere, IEnumerable<object> container)
{
var successCount = 0;
var subResult = new Result();
foreach (var route in container)
{
var cleanResult = new Result {Target = route};
var localPath = pathHere;
ApplyPredicatesToSimpleTerminal(localPath, cleanResult, predicates);
subResult.Merge(cleanResult);
if (cleanResult.Success) successCount++;
}
if (successCount < 1)
{
result.Merge(subResult);
}
}
示例3: CheckAnySubpaths
static void CheckAnySubpaths(Result result, IList<INamedPredicate> predicates, List<ChainStep> remainingChain, string pathHere, IEnumerable<object> container)
{
var successCount = 0;
var subResult = new Result();
foreach (var route in container)
{
var cleanResult = new Result {Target = route};
var localPath = pathHere;
WalkObjectTree(remainingChain, ref localPath, cleanResult, predicates);
subResult.Merge(cleanResult);
if (cleanResult.Success) successCount++;
}
if (successCount < 1)
{
result.Merge(subResult);
}
}
示例4: CheckAllSubpaths
static void CheckAllSubpaths(Result result, IList<INamedPredicate> predicates, string pathHere, List<ChainStep> remainingChain, IEnumerable<object> container)
{
var i = 0;
foreach (var route in container)
{
var cleanResult = new Result {Target = route};
var localPath = pathHere + "[" + i + "]";
WalkObjectTree(remainingChain, ref localPath, cleanResult, predicates);
result.Merge(cleanResult);
i++;
}
}
示例5: CheckAll
static void CheckAll(Result result, IList<INamedPredicate> predicates, string pathHere, IEnumerable<object> container)
{
var i = 0;
foreach (var route in container)
{
var cleanResult = new Result {Target = route};
var localPath = pathHere + "[" + i + "]";
ApplyPredicatesToSimpleTerminal(localPath, cleanResult, predicates);
result.Merge(cleanResult);
i++;
}
}
示例6: ApplyPredicatesToTerminalEnumerable
static void ApplyPredicatesToTerminalEnumerable(string path, Result result, IList<INamedPredicate> predicates, ChainStep step)
{
string stepMsg;
var container = FilterWithNamedPredicate((IEnumerable)result.Target, step, out stepMsg);
path += stepMsg;
object target;
switch (step.ListAssertionType)
{
case ListAssertion.Simple:
ApplyPredicatesToSimpleTerminal(path, result, predicates);
break;
case ListAssertion.Single:
if (!StepSingle(result, path, container, out target)) return;
var singleResult = new Result{Target = target};
ApplyPredicatesToSimpleTerminal(path, singleResult, predicates);
result.Merge(singleResult);
break;
case ListAssertion.Index:
if (!StepIndex(result, step, container, out target, ref path)) return;
var indexResult = new Result{Target = target};
ApplyPredicatesToSimpleTerminal(path, indexResult, predicates);
result.Merge(indexResult);
break;
case ListAssertion.All:
CheckAll(result, predicates, path, container);
return;
case ListAssertion.Any:
CheckAny(result, predicates, path, container);
return;
default:
throw new Exception("Unexpected list assertion type");
}
}
示例7: AllWithSubject
static Result AllWithSubject(object subject, params Func<dynamic, Result>[] cases)
{
var result = new Result();
foreach (var check in cases)
{
result.Merge(check(That(subject)));
}
return result;
}
示例8: AllWithStems
static Result AllWithStems(IEnumerable<Check> subjects, params Func<dynamic, Result>[] cases)
{
var result = new Result();
foreach (var subject in subjects)
{
foreach (var check in cases)
{
result.Merge(check(subject));
}
}
return result;
}