本文整理汇总了C#中SortedList.Count方法的典型用法代码示例。如果您正苦于以下问题:C# SortedList.Count方法的具体用法?C# SortedList.Count怎么用?C# SortedList.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedList
的用法示例。
在下文中一共展示了SortedList.Count方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KeyboardBehaviour
public KeyboardBehaviour(IEnumerable<AvengersUtd.Odyssey.UserInterface.Input.KeyBinding> keyBindings)
{
this.keyBindings = new SortedList<Keys, KeyBinding>();
foreach (KeyBinding kb in keyBindings)
this.keyBindings.Add(kb.Key, kb);
actions = new bool[keyBindings.Count()];
}
示例2: AverageRolling
//method that returns a SL of adjusted close rolling averages based on specified days
public static SortedList<DateTime, double> AverageRolling(DataTable dt, int numDays)
{
numDays = 100;
//instantiate SL for holding the rolling average of adjusted closes of N days
SortedList<DateTime, double> rollingaverage = new SortedList<DateTime, double>();
SortedList<DateTime, double> calculation = new SortedList<DateTime, double>();
//query the market table with LINQ for Date and Adjusted Close
var query = from data in dt.AsEnumerable()
select new
{
Date = data.Field<DateTime>("Date"),
AdjClose = data.Field<double>("AdjustedClose")
};
//load the calculation SL for computations
foreach (var item in query)
calculation.Add(item.Date, item.AdjClose);
//calculate and add rolling average of adjusted closes
for (int i = 0; i < calculation.Count(); i++)
{
if (i >= numDays - 1)
{
//array for numDays of adjusted closes to average
double[] prices = new double[numDays];
//load adjusted closes into arrays
for (int j = numDays; j > 0; j--)
{
prices[j - 1] = calculation.Values[(i + 1) - j];
}
rollingaverage.Add(calculation.Keys[i], prices.Average());
}
}
return rollingaverage;
}
示例3: pathTo
public PathData pathTo(Pos target, Pos currentLocation, Tile[][] board, int spikeCost = 10)
{
spikePrice = spikeCost;
//int resultCost = 0;
PathData pathData = new PathData();
int size = board.GetLength(0);
int[][] pointValues = new int[size][];
for (int x = 0; x < size; x++)
{
pointValues[x] = new int[size];
}
pointValues[currentLocation.x][currentLocation.y] = 1;
SortedList<int, Pos> newMarkedPoints = new SortedList<int, Pos>(new DuplicateKeyComparer<int>());
newMarkedPoints.Add(1, currentLocation);
size--;
while (newMarkedPoints.Count() != 0) {
Pos pos = newMarkedPoints.First().Value;
newMarkedPoints.RemoveAt(0);
int basecost = pointValues[pos.x][pos.y];
int x;
int y;
x = pos.x;
y = pos.y + 1;
if(x<= size && x >=0 && y <= size && y >=0) {
if (target.x == x && target.y == y) {
pathData.distance = tilePrice(board[x][y]) + basecost + 1;
break;
}
if (tilePrice(board[x][y]) != -1 && pointValues[x][y] == 0) {
pointValues[x][y] = tilePrice(board[x][y]) + basecost + 1;
newMarkedPoints.Add(pointValues[x][y], new Pos(x, y));
}
}
x = pos.x + 1;
y = pos.y;
if(x<= size && x >=0 && y <= size && y >=0) {
if (target.x == x && target.y == y) {
pathData.distance = tilePrice(board[x][y]) + basecost + 1;
break;
}
if (tilePrice(board[x][y]) != -1 && pointValues[x][y] == 0) {
pointValues[x][y] = tilePrice(board[x][y]) + basecost + 1;
newMarkedPoints.Add(pointValues[x][y], new Pos(x, y));
}
}
x = pos.x - 1;
y = pos.y;
if(x<= size && x >=0 && y <= size && y >=0) {
if (target.x == x && target.y == y) {
pathData.distance = tilePrice(board[x][y]) + basecost + 1;
break;
}
if (tilePrice(board[x][y]) != -1 && pointValues[x][y] == 0) {
pointValues[x][y] = tilePrice(board[x][y]) + basecost + 1;
newMarkedPoints.Add(pointValues[x][y], new Pos(x, y));
}
}
x = pos.x;
y = pos.y - 1;
if(x<= size && x >=0 && y <= size && y >=0) {
if (target.x == x && target.y == y) {
pathData.distance = tilePrice(board[x][y]) + basecost + 1;
break;
}
if (tilePrice(board[x][y]) != -1 && pointValues[x][y] == 0) {
pointValues[x][y] = tilePrice(board[x][y]) + basecost + 1;
newMarkedPoints.Add(pointValues[x][y], new Pos(x, y));
}
}
}
//Console.Out.WriteLine(resultCost);
//backtrace
Pos currentPos = target;
while (true) {
//Console.Out.WriteLine(currentPos.x + "," + currentPos.y);
int x, y, a=99999,b=99999,c=99999,d=99999;
x = currentPos.x - 1;
y = currentPos.y;
if (x <= size && x >= 0 && y <= size && y >= 0) {
if (currentLocation.x == x && currentLocation.y == y) {
pathData.nextDirection = Direction.South;
break;
}
a = pointValues[x][y];
}
x = currentPos.x;
y = currentPos.y - 1;
if (x <= size && x >= 0 && y <= size && y >= 0) {
if (currentLocation.x == x && currentLocation.y == y) {
pathData.nextDirection = Direction.East;
break;
}
b = pointValues[x][y];
}
x = currentPos.x;
y = currentPos.y + 1;
//.........这里部分代码省略.........
示例4: CheckForFailures
private bool CheckForFailures(Dictionary<Command, string> commands)
{
System.Collections.Generic.SortedList<Type, bool> nextNeededCommands = new SortedList<Type, bool>();
for (int i = 0; i < commands.Count; i++)
{
foreach (Type t in commands.Keys.ElementAt(i).NeededCommands)
{
nextNeededCommands.Add(t, true);
}
if (nextNeededCommands.Count > 0)
{
for (int a = 0; a < nextNeededCommands.Count; a++)
{
if (commands.Keys.Count(f => f.GetType() == nextNeededCommands.Keys.ElementAt(a)) > 0)
{
nextNeededCommands.RemoveAt(a);
}
}
}
}
return nextNeededCommands.Count(f => f.Value == true) == 0;
}
示例5: InitRadioButtons
protected void InitRadioButtons(string[,] aLaunchExtensions, string aUrl, string aResourceID, RadioGroup aRadioGroup)
{
aRadioGroup.RemoveAllViews();
SortedList<int, RadioButton> _myList = new SortedList<int, RadioButton>();
for (int i = 0; i < aLaunchExtensions.GetLength(0); i++)
{
string _curS = aLaunchExtensions[i, 0];
string _curParam = aLaunchExtensions[i, 1];
RadioButton _button = new RadioButton(this);
_button.Text = string.Format("{0} [{1}]",_curS,_curParam);
_button.Tag = i;
string _resourceName = aResourceID + _curParam;
if (_resourceName == aResourceID)
{ _resourceName = aResourceID+"nothing"; };
// int _resourceID = Resources.GetIdentifier(_resourceName, "drawable", this.PackageName);
if (_resourceName != "nothing")
{
try
{
var _resourceID = (int)typeof(Resource.Drawable).GetField(_resourceName).GetValue(null);
if (_resourceID > 0)
{
Android.Graphics.Drawables.Drawable _d = Resources.GetDrawable(_resourceID);
_d.SetBounds(0, 0, 120, 120);
_button.SetCompoundDrawables(_d, null, null, null);
};
}
catch { };
};
aRadioGroup.AddView(_button);
if ((aUrl.IndexOf(_curParam) >= 0) && (_curParam != ""))
{
_myList.Add(_curParam.Length, _button);
};
};
if (_myList.Count > 0)
{
RadioButton _button = _myList.Values[_myList.Count() - 1];
aRadioGroup.Check(_button.Id);
};
}
示例6: GetInactiveCategories
//GetInactiveCategories
public object GetInactiveCategories(long event_id)
{
List<EventCategory> event_cats = (from E in dataContext.EventCategories
where !E.IsActive && E.Event_ID == event_id
select E).ToList();
SortedList<string, long> cats = new SortedList<string, long>();
foreach (EventCategory ec in event_cats)
{
string str = ec.FullCategory;
if (!cats.ContainsKey(str))
cats.Add(str, ec.ID);
}
var jsonData = new
{
total = 1,
page = 1,
records = cats.Count(),
rows = (
from query in cats
select new
{
i = query.Value.ToString(),
cell = new string[] {
query.Value.ToString(),
query.Key,
}
}).ToArray()
};
event_cats = null;
cats = null;
return jsonData;
}
示例7: Returns
public static SortedList<DateTime, double> Returns(DataTable dt)
{
//instantiate SL for holding the rolling average of adjusted closes of N days
SortedList<DateTime, double> returns = new SortedList<DateTime, double>();
SortedList<DateTime, double> calculation = new SortedList<DateTime, double>();
//query the market table with LINQ for Date and Adjusted Close
var query = from data in dt.AsEnumerable()
select new
{
Date = data.Field<DateTime>("Date"),
AdjClose = data.Field<double>("AdjustedClose")
};
//load the calculation SL for computations
foreach (var item in query)
calculation.Add(item.Date, item.AdjClose);
//calculate and add static average of adjusted closes
double[] prices = new double[calculation.Count()];
for (int i = 0; i < calculation.Count(); i++)
{
//load adjusted closes into arrays
for (int k = 0; k < calculation.Count(); k++)
{
prices[k] = calculation.Values[k];
}
if (i > 0)
{
double rets = 0.00;
rets = (prices[i] - prices[i - 1]) / prices[i - 1];
returns.Add(calculation.Keys[i], rets);
}
}
return returns;
}
示例8: ZscoreStatic
public static SortedList<DateTime, double> ZscoreStatic(DataTable dt)
{
//instantiate SL for holding the rolling average of adjusted closes of N days
SortedList<DateTime, double> zscorestatic = new SortedList<DateTime, double>();
SortedList<DateTime, double> calculation = new SortedList<DateTime, double>();
//query the market table with LINQ for Date and Adjusted Close
var query = from data in dt.AsEnumerable()
select new
{
Date = data.Field<DateTime>("Date"),
AdjClose = data.Field<double>("Open")
};
//load the calculation SL for computations
foreach (var item in query)
calculation.Add(item.Date, item.AdjClose);
//calculate and add static average of adjusted closes
double[] prices = new double[calculation.Count()];
for (int i = 0; i < calculation.Count(); i++)
{
//load adjusted closes into arrays
for (int k = 0; k < calculation.Count(); k++)
{
prices[k] = calculation.Values[k];
}
double zscoreStatic = 0.00;
zscoreStatic = (prices[i] - prices.Average()) / StdDevAllCloseA(prices);
zscorestatic.Add(calculation.Keys[i], zscoreStatic);
}
return zscorestatic;
}