本文整理汇总了C#中SortedList类的典型用法代码示例。如果您正苦于以下问题:C# SortedList类的具体用法?C# SortedList怎么用?C# SortedList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SortedList类属于命名空间,在下文中一共展示了SortedList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getBeforeAndAfterKeys
public List<double> getBeforeAndAfterKeys(SortedList<double, double> aSortedList, double pseudoKey)
{
double before = 0;
double after = 0;
this.getBeforeAndAfterKeys(aSortedList, pseudoKey, ref before, ref after);
return new List<double>{before, after};
}
示例2: rptTeams_ItemDataBound
protected void rptTeams_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
DropDownList drpStanding = (DropDownList)e.Item.FindControl("drpStanding");
int year = cf.getMaxYear();
SortedList teams = new SortedList();
int cnt = 0;
if (Session["user"] != null)
{
user u = (user)Session["user"];
teams = u.get_teams();
rptTeams.DataSource = null;
}
if (teams == null)
{
teams = cf.getTeams(year);
}
cnt = teams.Count;
for (int i = 0; i < cnt; i++)
{
int s = i + 1;
drpStanding.Items.Add(new ListItem(s.ToString(), s.ToString()));
}
try
{
drpStanding.SelectedIndex = e.Item.ItemIndex;
}
catch (Exception ex)
{
cf.logError(ex);
}
}
示例3: Updater
public Updater(FileTransfer fileTransfer)
{
this.fileTransfer = fileTransfer;
filesToDelete = new SortedList<string, string>();
filesToDownload = new SortedList<string,TransferFile>();
updaterConfig = new UpdaterConfig();
}
示例4: MainForm
public MainForm(string configPath, bool minimize)
{
Config config;
string message;
this.InitializeComponent();
this.toolStripMenuItemName.Text += Assembly.GetExecutingAssembly().GetName().Version.ToString(2);
this.Icon = Resources.AppIcon;
this.rules = new Dictionary<string, Rule>();
this.configPath = configPath;
this.minimize = minimize;
this.points = new SortedList<int, Point>();
if (!File.Exists(configPath))
config = new Config();
else if (!Config.TryParse(File.ReadAllText(configPath), out config, out message))
{
this.toolStripStatusLabel.Text = string.Format(CultureInfo.InvariantCulture, "Configuration error: {0}", message);
config = new Config();
}
this.ConfigSet(config);
this.ModeConfigRadioCheckedChanged(this, new EventArgs());
}
示例5: GetPatents
//read XML file for patent info
public static SortedList<int, Patent> GetPatents()
{
XmlDocument doc = new XmlDocument();
//if file doesn't exist, create it
if (!File.Exists("Patents.xml"))
doc.Save("Patents.xml");
SortedList<int, Patent> patents = new SortedList<int, Patent>();
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.IgnoreWhitespace = true;
readerSettings.IgnoreComments = true;
XmlReader readXml = null;
try
{
readXml = XmlReader.Create(path, readerSettings);
if (readXml.ReadToDescendant("Patent")) //read to first Patent node
{
do
{
Patent patent = new Patent();
patent.Number = Convert.ToInt32(readXml["Number"]);
readXml.ReadStartElement("Patent");
patent.AppNumber = readXml.ReadElementContentAsString();
patent.Description = readXml.ReadElementContentAsString();
patent.FilingDate = DateTime.Parse(readXml.ReadElementContentAsString());
patent.Inventor = readXml.ReadElementContentAsString();
patent.Inventor2 = readXml.ReadElementContentAsString();
int key = patent.Number; //assign key to value
patents.Add(key, patent); //add key-value pair to list
}
while (readXml.ReadToNextSibling("Patent"));
}
}
catch (XmlException ex)
{
MessageBox.Show(ex.Message, "Xml Error");
}
catch (IOException ex)
{
MessageBox.Show(ex.Message, "IO Exception");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Exception Occurred");
}
finally
{
if (readXml != null)
readXml.Close();
}
return patents;
}
示例6: CalculateAverage
public List<Measure> CalculateAverage()
{
//return empty MeasureList if no measures where added
if ((_inputList == null) || (_inputList.Count == 0))
{
return new List<Measure>();
}
//Get the average measures for all logminutes
SortedList<DateTime, MeasureMinute> calcList = new SortedList<DateTime, MeasureMinute>();
foreach (var measure in _inputList)
{
var currentMeasureTime = Utils.GetWith0Second(measure.DateTime);
if (!calcList.ContainsKey(currentMeasureTime))
{
calcList.Add(currentMeasureTime, new MeasureMinute(currentMeasureTime));
}
calcList[currentMeasureTime].AddMeasure(measure);
}
List<Measure> result = new List<Measure>();
foreach (var logMinute in calcList.Values)
{
result.AddRange(logMinute.CalculateAverage());
}
return result;
}
示例7: ContainsNearbyAlmostDuplicate
public bool ContainsNearbyAlmostDuplicate(int[] nums, int k, int t)
{
if (k <= 0 || t < 0) return false;
var index = new SortedList<int, object>();
for (int i = 0; i < nums.Length; ++i)
{
if (index.ContainsKey(nums[i]))
{
return true;
}
index.Add(nums[i], null);
var j = index.IndexOfKey(nums[i]);
if (j > 0 && (long)nums[i] - index.Keys[j - 1] <= t)
{
return true;
}
if (j < index.Count - 1 && (long)index.Keys[j + 1] - nums[i] <= t)
{
return true;
}
if (index.Count > k)
{
index.Remove(nums[i - k]);
}
}
return false;
}
示例8: flushToDatabase
//This is the function that is used to put buffered data on the database
public bool flushToDatabase()
{
//Set to correct database
mysql.switchDatabase("crex_forwardmetric");
Console.WriteLine("Flushing To Forward Metric...");
Console.WriteLine("0%");
string returnval = "";
//Go through all the data and add it efficiently
for(int i = 0; i < data.Count;i++)
{
returnval+=mysql.issueCommand("create table if not exists `"+data.Keys[i]+"` (wordStrings char(50), wordCounts integer unsigned, primary key (wordStrings));");
if(data.Values[i].Count==0) continue;
string command = "insert into `"+data.Keys[i]+"` (wordStrings,wordCounts) values ";
for(int j = 0; j < data.Values[i].Count;j++)
command+="('"+data.Values[i][j]+"',1),";
command = command.Remove(command.Length-1);
command+=" on duplicate key update wordCounts=wordCounts+1;";
returnval+=mysql.issueCommand(command);
Console.SetCursorPosition(0, Console.CursorTop - 1);
Console.WriteLine((int)((double)((double)i/(double)data.Count)*100.00)+"%");
}
Console.SetCursorPosition(0, Console.CursorTop - 1);
Console.WriteLine("100%");
Console.WriteLine("Done Flushing to Forward Metric...");
//Reset data
data = new SortedList<string, List<string>>();
if(returnval!="") return false;
return true;
}
示例9: CovertChatLogsToDialogue
public static void CovertChatLogsToDialogue(ref SortedList<DateTime, List<ChatWord>> chatLogs, ref SortedList<DateTime, List<ChatDialogue>> chatDialogues, int timeSpan = 60)
{
DateTime currentDate = DateTime.Today;
DateTime currentDateTime = DateTime.Today;
foreach (var dialogue in chatLogs)
{
if (currentDateTime.Equals(DateTime.Today) || (dialogue.Value.First().timeStamp - currentDateTime).TotalMinutes > timeSpan)
{
chatDialogues.Add(dialogue.Key, new List<ChatDialogue>());
currentDate = dialogue.Key;
}
foreach (var log in dialogue.Value)
{
if (currentDateTime.Equals(DateTime.Today) || (log.timeStamp - currentDateTime).TotalMinutes > timeSpan)
{
if (!currentDate.Date.Equals(log.timeStamp.Date))
{
chatDialogues.Add(dialogue.Key, new List<ChatDialogue>());
currentDate = dialogue.Key;
}
chatDialogues[currentDate].Add(new ChatDialogue(log.timeStamp));
}
chatDialogues[currentDate].Last().chatWords.Add(log);
currentDateTime = log.timeStamp;
}
}
}
示例10: GetExternalActions
private SortedList<int, IAction> GetExternalActions(IPolicyChannel channel)
{
SortedList<int, IAction> externalActions = new SortedList<int, IAction>();
IRoutingTable routing = channel.Routing;
if (routing == null)
return externalActions;
Guid unprivDestinationId = routing.DefaultDestination.Identifier;
Guid unprivSourceId = routing.DefaultSource.Identifier;
IRoutingMatrixCell routingMatrixCell = routing[unprivSourceId, unprivDestinationId];
if (routingMatrixCell == null)
return externalActions;
IActionMatrixCell actionMatrixCell = channel.Actions[unprivSourceId, unprivDestinationId];
if (actionMatrixCell == null)
return externalActions;
foreach (IActionConditionGroup actionCondtionGroup in actionMatrixCell.ActionConditionGroups)
{
foreach (IAction action in actionCondtionGroup.ActionGroup.Actions)
{
externalActions.Add(action.Precedence, action);
}
}
return externalActions;
}
示例11: ForwardMetric
public ForwardMetric()
{
//Star SQL Connection and set data to null
data = new SortedList<string, List<string>>();
mysql = new SQLInterface();
mysql.connect(Program.mysqlusername, Program.mysqlpass, Program.mysqldatabase, Program.mysqlservername);
}
示例12: TabStandards
public TabStandards(string standardsFile)
{
FilePath = standardsFile;
StandardsList = new SortedList<long, NZQAStandard>();
LatestVersions = new SortedList<int, int>();
bool firstLine = true;
int lineNumber = 1;
foreach (var line in File.ReadAllLines(standardsFile))
{
if (firstLine)
{
firstLine = false;
if (!line.Contains(DELIMETER)) continue;
}
var std = ParseLine(line, lineNumber++);
var stdNo = std.StandardNumber;
var verNo = std.Version;
StandardsList[ToKey(stdNo, verNo)] = std;
if (( !LatestVersions.ContainsKey(stdNo)) || LatestVersions[stdNo] < verNo)
{
LatestVersions[stdNo] = verNo;
if (std.IsInternal) StandardsList[ToKey(stdNo, MAX_VERSION)] = std;
}
}
}
示例13: StopSpider
public StopSpider(IPAddress providerDNS, IPAddress censorRedirect, string provider, string country, string reporter)
{
// initiate spiderlist
this.providerDNS = providerDNS;
this.censorRedirect = censorRedirect;
this.provider = provider;
this.country = country;
this.reporter = reporter;
this.openDnsResolver = new Resolver(Resolver.DefaultDnsServers[0]);
// add an initial list in randomized order, this will also prevent adding already known urls!
SortedList<int, string> rlist = new SortedList<int, string>();
TextReader inputurls = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("shortlist.txt"));
string url; Random r = new Random();
while ((url = inputurls.ReadLine()) != null)
{
rlist.Add(r.Next(), url);
}
foreach (string uri in rlist.Values)
{
spiderlist.Add(new SpiderInfo(uri, 0));
spidercheck.Add(uri, true);
}
}
示例14: ResetControls
/// <summary>
/// Resets all boxes.
/// </summary>
public void ResetControls()
{
txtCodeName.Text = null;
txtDisplayName.Text = null;
//Fill drop down list
DataHelper.FillWithEnum<AnalyzerTypeEnum>(drpAnalyzer, "srch.index.", SearchIndexInfoProvider.AnalyzerEnumToString, true);
drpAnalyzer.SelectedValue = SearchIndexInfoProvider.AnalyzerEnumToString(AnalyzerTypeEnum.StandardAnalyzer);
chkAddIndexToCurrentSite.Checked = true;
// Create sorted list for drop down values
SortedList sortedList = new SortedList();
sortedList.Add(GetString("srch.index.doctype"), PredefinedObjectType.DOCUMENT);
// Allow forum only if module is available
if ((ModuleEntry.IsModuleRegistered(ModuleEntry.FORUMS) && ModuleEntry.IsModuleLoaded(ModuleEntry.FORUMS)))
{
sortedList.Add(GetString("srch.index.forumtype"), PredefinedObjectType.FORUM);
}
sortedList.Add(GetString("srch.index.usertype"), PredefinedObjectType.USER);
sortedList.Add(GetString("srch.index.customtabletype"), SettingsObjectType.CUSTOMTABLE);
sortedList.Add(GetString("srch.index.customsearch"), SearchHelper.CUSTOM_SEARCH_INDEX);
sortedList.Add(GetString("srch.index.doctypecrawler"), SearchHelper.DOCUMENTS_CRAWLER_INDEX);
sortedList.Add(GetString("srch.index.general"), SearchHelper.GENERALINDEX);
drpType.DataValueField = "value";
drpType.DataTextField = "key";
drpType.DataSource = sortedList;
drpType.DataBind();
// Pre-select documents index
drpType.SelectedValue = PredefinedObjectType.DOCUMENT;
}
示例15: GetPeersTask
public GetPeersTask(DhtEngine engine, NodeId infohash)
{
this.engine = engine;
this.infoHash = infohash;
this.closestNodes = new SortedList<NodeId, NodeId>(Bucket.MaxCapacity);
this.queriedNodes = new SortedList<NodeId, Node>(Bucket.MaxCapacity * 2);
}