本文整理汇总了C#中ICollection.Min方法的典型用法代码示例。如果您正苦于以下问题:C# ICollection.Min方法的具体用法?C# ICollection.Min怎么用?C# ICollection.Min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICollection
的用法示例。
在下文中一共展示了ICollection.Min方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Combine
public static Region Combine(ICollection<Region> regions)
{
var start = regions.Min(x => x.Start);
var end = regions.Max(x => x.End);
var paddedEnd = regions.Max(x => x.PaddedEnd);
return new Region(start, (int)(end - start), (int)(paddedEnd - start));
}
示例2: FoldChangeDataSet
public FoldChangeDataSet(ICollection<double> abundances, ICollection<int> features, ICollection<int> runs, ICollection<int> subjects, ICollection<bool> subjectControls)
{
Abundances = ImmutableList.ValueOf(abundances);
Runs = ImmutableList.ValueOf(runs);
Features = ImmutableList.ValueOf(features);
Subjects = ImmutableList.ValueOf(subjects);
SubjectControls = ImmutableList.ValueOf(subjectControls);
if (abundances.Count != features.Count || abundances.Count != subjects.Count || abundances.Count != Runs.Count)
{
throw new ArgumentException("Wrong number of rows"); // Not L10N
}
if (abundances.Count == 0)
{
FeatureCount = 0;
SubjectCount = 0;
RunCount = 0;
}
else
{
if (features.Min() < 0 || Runs.Min() < 0 || subjects.Min() < 0)
{
throw new ArgumentException("Cannot be negative"); // Not L10N
}
FeatureCount = Features.Max() + 1;
SubjectCount = Subjects.Max() + 1;
RunCount = Runs.Max() + 1;
}
if (subjectControls.Count != SubjectCount)
{
throw new ArgumentException("Wrong number of subjects"); // Not L10N
}
}
示例3: Combine
public static DataCenterRegion Combine(ICollection<DataCenterRegion> regions)
{
var start = regions.Min(x => x.Start);
var end = regions.Max(x => x.End);
var paddedEnd = regions.Max(x => x.PaddedEnd);
var elementSize = regions.Select(x => x.ElementSize).Distinct().Single();
return new DataCenterRegion(start, (int)(end - start), (int)(paddedEnd - start), elementSize);
}
示例4: TimingStatSummary
public TimingStatSummary(ICollection<TimingStat> stats, DateTime start, DateTime end) {
Stats = stats;
Count = Stats.Sum(s => s.Count);
MinDuration = Stats.Min(s => s.MinDuration);
MaxDuration = Stats.Max(s => s.MaxDuration);
TotalDuration = Stats.Sum(s => s.TotalDuration);
AverageDuration = Count > 0 ? (double)TotalDuration / Count : 0;
StartTime = start;
EndTime = end;
}
示例5: GaugeStatSummary
public GaugeStatSummary(ICollection<GaugeStat> stats, DateTime start, DateTime end) {
Stats = stats;
Count = Stats.Sum(s => s.Count);
Total = Stats.Sum(s => s.Total);
Last = Stats.Last().Last;
Min = Stats.Min(s => s.Min);
Max = Stats.Max(s => s.Max);
StartTime = start;
EndTime = end;
Average = Count > 0 ? Total / Count : 0;
}
示例6: Calculate
public void Calculate(ICollection<Double> realization )
{
Rows = new Collection<IntervalData>();
this.variationRange = realization.Max() - realization.Min();
if (this.variationRange < 0.99)
{
this.variationRange = 1;
}
this.intervalLength = this.variationRange/IntervalNumber;
this.FindIntervalHits(realization);
}
示例7: GetTimeDiffOfNearestMeasurement
public TimeSpan GetTimeDiffOfNearestMeasurement(ICollection<Measurement> measurements, DateTime dateTime)
{
if (measurements == null || !measurements.Any())
{
return TimeSpan.MaxValue;
}
var nearestOldMeasurement = measurements.Min(m => m.LastUpdated > dateTime ? m.LastUpdated - dateTime : dateTime - m.LastUpdated);
return nearestOldMeasurement;
}
示例8: Histogram
public Histogram(ICollection<double> values, int numBins)
: this(values, values.Min(), values.Max(), numBins) { }
示例9: CalculateHistogramData
private static IEnumerable<double> CalculateHistogramData(ICollection<Double> realization )
{
ICollection<Double> result = new List<double>();
const Int32 intervalCount = 20;
Double maxVlaue = realization.Max();
Double minValue = realization.Min();
Double intervalLength = (maxVlaue - minValue) / intervalCount;
Double from = minValue;
Double to = minValue + intervalLength;
for (int i = 0; i < 20; ++i)
{
Int32 hits = realization.Count(r => r > from && r <= to );
Double probability = (Double)hits / realization.Count;
result.Add(probability);
from += intervalLength;
to += intervalLength;
}
return result;
}
示例10: GetSummaryReport
public static string GetSummaryReport(ICollection<SessionEx> sessions)
{
var res = new StringBuilder(DefaultBufferSize);
res.AppendLine("Name\tValue");
if (sessions.Count > 0)
{
var minDate = sessions.Min(session => session.LastUpdateTime);
res.AppendLine("MinDate\t{0}", minDate.ToString("yyyy-MM-dd HH:mm:ss"));
var maxDate = sessions.Max(session => session.LastUpdateTime);
res.AppendLine("MaxDate\t{0}", maxDate.ToString("yyyy-MM-dd HH:mm:ss"));
}
// append leading space as a workaround for the PowerPivot quirk
// http://social.msdn.microsoft.com/Forums/en-US/sqlkjpowerpivotforexcel/thread/456699ec-b5a2-4ae9-bc9f-b7ed2d637959
res.AppendLine("SessionsCount\t {0}", sessions.Count);
var latencyRecordsCount = sessions.Aggregate(0,
(val, session) => val + session.Records.Where(Util.IsLatency).Count());
res.AppendLine("LatencyRecordsCount\t {0}", latencyRecordsCount);
var jitterRecordsCount = sessions.Aggregate(0,
(val, session) => val + session.Records.Where(Util.IsJitter).Count());
res.AppendLine("JitterRecordsCount\t {0}", jitterRecordsCount);
return res.ToString();
}
示例11: SetFanMotifArcScale
protected void SetFanMotifArcScale(ICollection<Motif> oFanMotifs)
{
Debug.Assert(oFanMotifs != null);
// The ArcScale property is the FanMotif's leaf count scaled between 0
// and 1.0, based on the minimum and maximum leaf counts among all
// FanMotifs.
Int32 iMinimumLeafCount = 0;
Int32 iMaximumLeafCount = 0;
if (oFanMotifs.Count > 0)
{
iMinimumLeafCount = oFanMotifs.Min(
oMotif => ((FanMotif)oMotif).LeafVertices.Length);
iMaximumLeafCount = oFanMotifs.Max(
oMotif => ((FanMotif)oMotif).LeafVertices.Length);
}
foreach (FanMotif oFanMotif in oFanMotifs)
{
Single fArcScale;
if (iMinimumLeafCount == iMaximumLeafCount)
{
// All the leaf counts are the same. Arbitrarily set the
// ArcScale property to the center of the range.
fArcScale = 0.5F;
}
else
{
fArcScale = MathUtil.TransformValueToRange(
oFanMotif.LeafVertices.Length,
iMinimumLeafCount, iMaximumLeafCount,
0F, 1.0F
);
}
oFanMotif.ArcScale = fArcScale;
}
}
示例12: foreach
SetCliqueMotifScale
(
ICollection<Motif> oCliqueMotifs
)
{
Debug.Assert(oCliqueMotifs != null);
// The ArcScale property is the CliqueMotif's member count scaled between 0
// and 1.0, based on the minimum and maximum CliqueMotif counts among all
// CliqueMotifs.
Int32 iMinimumMemberCount = 0;
Int32 iMaximumMemberCount = 0;
if (oCliqueMotifs.Count > 0)
{
iMinimumMemberCount = oCliqueMotifs.Min(
oMotif => ((CliqueMotif)oMotif).MemberVertices.Count);
iMaximumMemberCount = oCliqueMotifs.Max(
oMotif => ((CliqueMotif)oMotif).MemberVertices.Count);
}
foreach (CliqueMotif oCliqueMotif in oCliqueMotifs)
{
Single fCliqueScale;
if (iMinimumMemberCount == iMaximumMemberCount)
{
// All the member counts are the same. Arbitrarily set the
// CliqueScale property to the center of the range.
fCliqueScale = 0.5F;
}
else
{
fCliqueScale = MathUtil.TransformValueToRange(
oCliqueMotif.MemberVertices.Count,
iMinimumMemberCount, iMaximumMemberCount,
0F, 1.0F
);
}
oCliqueMotif.CliqueScale = fCliqueScale;
}
}
示例13: DoStepResult
private static void DoStepResult(StringBuilder writer, string stepName, ICollection<CaseStep> steps, int depth = 0)
{
string preChar = "".PadLeft(depth * 4);
double minTime = steps.Min(t => t.Timer.MinTime);
double aveTime = steps.Average(t => t.Timer.AveTime);
double maxTime = steps.Max(t => t.Timer.MaxTime);
int successNum = steps.Sum(t => t.Timer.SuccessNum);
int failNum = steps.Sum(t => t.Timer.FailNum);
if (failNum > 0)
{
string error = string.Join("", steps.Select(t => t.Timer.Error).ToList());
TraceLog.WriteError("{0}", error);
}
writer.AppendFormat("{0}>>Step {1}: success:{2}, fail:{3}", preChar, stepName, successNum, failNum);
writer.AppendLine();
writer.AppendFormat("{0} AVE:\t{1}ms", preChar, aveTime.ToString("F6"));
writer.AppendLine();
writer.AppendFormat("{0} Min:\t{1}ms", preChar, minTime.ToString("F6"));
writer.AppendLine();
writer.AppendFormat("{0} Max:\t{1}ms", preChar, maxTime.ToString("F6"));
writer.AppendLine();
var childs = steps.Where(t => t.ChildStep != null).Select(t => t.ChildStep).ToArray();
if (childs.Length > 0)
{
DoStepResult(writer, childs[0].Action, childs, depth + 1);
}
}
示例14: SetDConnectorMotifSpanScale
protected void SetDConnectorMotifSpanScale (ICollection<Motif> oDConnectorMotifs)
{
Debug.Assert(oDConnectorMotifs != null);
// The SpanScale property is the DConnectorMotif's span count scaled
// between 0 and 1.0, based on the minimum and maximum span counts
// among all DConnectorMotifs.
Int32 iMinimumSpanCount = 0;
Int32 iMaximumSpanCount = 0;
if (oDConnectorMotifs.Count > 0)
{
iMinimumSpanCount = oDConnectorMotifs.Min(
oMotif => ((DConnectorMotif)oMotif).SpanVertices.Count);
iMaximumSpanCount = oDConnectorMotifs.Max(
oMotif => ((DConnectorMotif)oMotif).SpanVertices.Count);
}
foreach (DConnectorMotif oDConnectorMotif in oDConnectorMotifs)
{
Single fSpanScale;
if (iMinimumSpanCount == iMaximumSpanCount)
{
// All the span counts are the same. Arbitrarily set the
// SpanScale property to the center of the range.
fSpanScale = 0.5F;
}
else
{
fSpanScale = MathUtil.TransformValueToRange(
oDConnectorMotif.SpanVertices.Count,
iMinimumSpanCount, iMaximumSpanCount,
0F, 1.0F
);
}
oDConnectorMotif.SpanScale = fSpanScale;
}
}
示例15: DoStepResult
private static void DoStepResult(TaskSetting setting, StringBuilder writer, string stepName, ICollection<CaseStep> steps, int depth = 0,StepTimer st=null)
{
string preChar = "".PadLeft(depth * 4);
double minTime = steps.Min(t => t.Timer.MinTime);
double aveTime = steps.Average(t => t.Timer.AveTime);
double maxTime = steps.Max(t => t.Timer.MaxTime);
int successNum = steps.Sum(t => t.Timer.SuccessNum);
int failNum = steps.Sum(t => t.Timer.FailNum);
if (failNum > 0)
{
string error = string.Join("", steps.Select(t => t.Timer.Error).ToList());
TraceLog.WriteError("{0}", error);
}
writer.AppendFormat("====={0}-{1}({2})", setting.TaskName, stepName, DateTime.Now.ToString());
writer.AppendLine();
writer.AppendFormat("====={0}", setting.TaskDes);
writer.AppendLine();
writer.AppendFormat("{0}>>Step {1}: success:{2}, fail:{3}", preChar, stepName, successNum, failNum);
writer.AppendLine();
writer.AppendFormat("{0} AVE:\t{1}ms", preChar, aveTime.ToString("F6"));
writer.AppendLine();
writer.AppendFormat("{0} Min:\t{1}ms", preChar, minTime.ToString("F6"));
writer.AppendLine();
writer.AppendFormat("{0} Max:\t{1}ms", preChar, maxTime.ToString("F6"));
writer.AppendLine();
writer.AppendFormat("{0} TotalTime:\t{1}ms",preChar,st!=null ? st.RunTotalTime.ToString("F6"):"");
writer.AppendLine();
string info = "";
foreach(var v in steps)
{
if (v.DecodePacketInfo!="")
info += v.DecodePacketInfo + "\n";
}
if(info != "")
{
writer.AppendFormat("req/res:\n{0}",info);
writer.AppendLine();
}
var childs = steps.Where(t => t.ChildStep != null).Select(t => t.ChildStep).ToArray();
if (childs.Length > 0)
{
DoStepResult(setting,writer, childs[0].Action, childs, depth + 1);
}
writer.AppendFormat("====={0}-{1}:End", setting.TaskName,stepName);
writer.AppendLine();
}