本文整理汇总了C#中SortedDictionary.Min方法的典型用法代码示例。如果您正苦于以下问题:C# SortedDictionary.Min方法的具体用法?C# SortedDictionary.Min怎么用?C# SortedDictionary.Min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedDictionary
的用法示例。
在下文中一共展示了SortedDictionary.Min方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compress
//.........这里部分代码省略.........
data.Seek(4, SeekOrigin.Current);
var count = data.ReadValueU32(endian);
data.Seek(count * 4, SeekOrigin.Current);
data.Seek(20, SeekOrigin.Current);
}
const uint maxBlockSize = 0x100000;
Stream outputStream = new MemoryStream();
// copying pcc header
byte[] buffer = new byte[130];
uncompressedPcc.Seek(0, SeekOrigin.Begin);
uncompressedPcc.Read(buffer, 0, 130);
outputStream.Write(buffer, 0, buffer.Length);
//add compressed pcc flag
uncompressedPcc.Seek(12, SeekOrigin.Begin);
folderNameLength = uncompressedPcc.ReadValueS32();
folderNameByteLength =
folderNameLength >= 0 ? folderNameLength : (-folderNameLength * 2);
uncompressedPcc.Seek(folderNameByteLength, SeekOrigin.Current);
outputStream.Seek(uncompressedPcc.Position, SeekOrigin.Begin);
packageFlags = uncompressedPcc.ReadValueU32();
packageFlags |= 0x02000000; // add compression flag
outputStream.WriteValueU32(packageFlags);
outputStream.Seek(buffer.Length, SeekOrigin.Begin);
long outOffsetData;
long outOffsetBlockInfo;
long inOffsetData = namesOffset;
List<int> blockSizes = new List<int>();
int countSize = (int)(exportDataOffsets.Min(obj => obj.Key) - namesOffset);
//count the number of blocks and relative sizes
uint lastOffset = exportDataOffsets.Min(obj => obj.Key);
foreach (KeyValuePair<uint, uint> exportInfo in exportDataOffsets)
{
// part that adds empty spaces (leaved when editing export data and moved to the end of pcc) into the count
if (exportInfo.Key != lastOffset)
{
int emptySpace = (int)(exportInfo.Key - lastOffset);
if (countSize + emptySpace > maxBlockSize)
{
blockSizes.Add(countSize);
countSize = 0;
}
else
countSize += emptySpace;
}
// adds export data into the count
if (countSize + exportInfo.Value > maxBlockSize)
{
blockSizes.Add(countSize);
countSize = (int)exportInfo.Value;
}
else
{
countSize += (int)exportInfo.Value;
}
lastOffset = exportInfo.Key + exportInfo.Value;
}
blockSizes.Add(countSize);
示例2: CalculateAggregate
private List<SortedDictionary<double, double>> CalculateAggregate(SortedDictionary<double, double> input)
{
var ypercentage = 0.0;
var xpoints = input.Count;
var minlist = new SortedDictionary<double, double>();
var avglist = new SortedDictionary<double, double>();
var maxlist = new SortedDictionary<double, double>();
while (ypercentage < 0.95)
{
minlist.Clear();
maxlist.Clear();
avglist.Clear();
var hist = new SortedDictionary<int, List<double>>();
var min = input.Min(k => k.Key);
var max = input.Max(k => k.Key);
xpoints = xpoints/2;
var buckets = ((max - min)/(xpoints));
foreach (var va in input)
{
var bucket = 0;
if (buckets > 0)
{
bucket = (int) ((va.Key - min)/buckets);
if (bucket == xpoints)
bucket--;
}
if (!hist.ContainsKey(bucket))
{
hist[bucket] = new List<double>();
}
hist[bucket].Add(va.Value);
}
var totaldiff = input.Max(k => k.Value) - input.Min(k => k.Value);
var diff = 0.0;
foreach (var val in hist)
{
minlist[min + (val.Key*buckets)] = val.Value.Min();
avglist[min + (val.Key*buckets)] = val.Value.Average();
maxlist[min + (val.Key*buckets)] = val.Value.Max();
diff += (val.Value.Max() - val.Value.Min())/hist.Count;
}
ypercentage = diff/totaldiff;
}
return new List<SortedDictionary<double, double>>() { minlist, avglist, maxlist }; ;
}