本文整理汇总了C#中SortedList.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# SortedList.ContainsKey方法的具体用法?C# SortedList.ContainsKey怎么用?C# SortedList.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedList
的用法示例。
在下文中一共展示了SortedList.ContainsKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: lb_mvtypes_SelectedIndexChanged
private void lb_mvtypes_SelectedIndexChanged(object sender, EventArgs e)
{
String t = lb_mvtypes.SelectedItem.ToString();
PythonReader pr = null;
if (t == "common") { pr = StaticDataHolder.Header_Common; }
else if (t == "operations") { pr = StaticDataHolder.Header_Operations; }
else if (t == "triggers") { pr = StaticDataHolder.Header_Triggers; }
lb_mvnames.Items.Clear();
SortedList<String, byte> tempsort = new SortedList<string, byte>();
for (int j = 0; j < pr.Items.Length; ++j)
{
if (tempsort.ContainsKey(pr.Items[j].Name))
{
for (int k = 0; k < 100; ++k)
{
if (!tempsort.ContainsKey(pr.Items[j].Name + "(" + k.ToString() + ")"))
{
tempsort.Add(pr.Items[j].Name + "(" + k.ToString() + ")", 0);
k = 100;
}
}
}
else { tempsort.Add(pr.Items[j].Name, 0); }
}
foreach (KeyValuePair<String, byte> kvp in tempsort) { lb_mvnames.Items.Add(kvp.Key); }
}
示例2: ComputeChildList
public static SortedList<string, Either<TreeTreeReference, TreeBlobReference>> ComputeChildList(IEnumerable<TreeTreeReference> treeRefs, IEnumerable<TreeBlobReference> blobRefs)
{
// Sort refs by name:
var namedRefs = new SortedList<string, Either<TreeTreeReference, TreeBlobReference>>(treeRefs.Count() + blobRefs.Count(), StringComparer.Ordinal);
// Add tree refs:
foreach (var tr in treeRefs)
{
if (namedRefs.ContainsKey(tr.Name))
throw new InvalidOperationException();
namedRefs.Add(tr.Name, tr);
}
// Add blob refs:
foreach (var bl in blobRefs)
{
if (namedRefs.ContainsKey(bl.Name))
throw new InvalidOperationException();
namedRefs.Add(bl.Name, bl);
}
return namedRefs;
}
示例3: GuiDisplayObject
public GuiDisplayObject(SortedList args)
{
//Pflichtfelde
if(args.ContainsKey("rect") == false){
throw new Exception("No Rect defined");
}
//Text
_text = "";
if(args.ContainsKey("text")){
_text = (string) args["text"];
}
_args = args;
_id = _idCounter++;
_go2D = new GameObject("2D GameObject - " + _id);
//Position
_rect = (Rect) args["rect"];
_widget = _go2D.AddComponent<GuiWidget>();
_widget.LocalPosition = new Vector2(_rect.x, _rect.y);
_widget.Dimension = new Vector2(_rect.width, _rect.height);
//make active
Visible = true;
}
示例4: Main
static void Main(string[] args)
{
string output_path = Path.GetDirectoryName (Application.ExecutablePath);
// Get the assemblies we want to examine
List<string> mono_assemblies = AssemblyManager.GetAssemblies (true, use_20, use_30, use_35, use_40, use_mobile, use_design, mwf_only);
List<string> ms_assemblies = AssemblyManager.GetAssemblies (false, use_20, use_30, use_35, use_40, use_mobile, use_design, mwf_only);
// Extract all methods from the MS assemblies
SortedList<string, Method> ms_all = new SortedList<string, Method> ();
foreach (string assembly in ms_assemblies)
MethodExtractor.ExtractFromAssembly (assembly, ms_all, null, null);
// Extract all, NIEX, and TODO methods from Mono assemblies
SortedList<string, Method> missing = new SortedList<string, Method> ();
SortedList<string, Method> all = new SortedList<string, Method> ();
SortedList<string, Method> todo = new SortedList<string, Method> ();
SortedList<string, Method> nie = new SortedList<string, Method> ();
foreach (string assembly in mono_assemblies)
MethodExtractor.ExtractFromAssembly (assembly, all, nie, todo);
// Only report the TODO's that are also in MS's assemblies
SortedList<string, Method> final_todo = new SortedList<string, Method> ();
foreach (string s in todo.Keys)
if (ms_all.ContainsKey (s))
final_todo[s] = todo[s];
WriteListToFile (final_todo, Path.Combine (output_path, "monotodo.txt"), true);
// Only report the NIEX's that are also in MS's assemblies
SortedList<string, Method> final_nie = new SortedList<string, Method> ();
foreach (string s in nie.Keys)
if (ms_all.ContainsKey (s))
final_nie[s] = nie[s];
WriteListToFile (final_nie, Path.Combine (output_path, "exception.txt"), false);
// Write methods that are both TODO and NIEX
SortedList<string, Method> todo_niex = new SortedList<string, Method> ();
foreach (string s in nie.Keys)
if (todo.ContainsKey (s))
todo_niex.Add (s, todo[s]);
WriteListToFile (todo_niex, Path.Combine (output_path, "dupe.txt"), true);
// Find methods that exist in MS but not in Mono (Missing methods)
MethodExtractor.ComputeMethodDifference (ms_all, all, missing, use_design);
WriteListToFile (missing, Path.Combine (output_path, "missing.txt"), false);
Console.WriteLine ("done");
Console.ReadLine ();
}
示例5: AppendConfigSegment
public void AppendConfigSegment(StringBuilder bd)
{
SortedList<ushort, bool> watch_port = new SortedList<ushort, bool>();
SortedList<string, IPAddress> watch_ip = new SortedList<string, IPAddress>();
SortedList<string, IPPair> watch_scope = new SortedList<string, IPPair>();
SortedList<string, bool> added_scope = new SortedList<string, bool>();
foreach (VirtualSite site in virtualSites_)
{
foreach (IPPair p in site.IPPairs)
{
if (!watch_port.ContainsKey(p.Port))
watch_port.Add(p.Port, true);
if (p.IPAddress != null && !watch_ip.ContainsKey(p.IPAddress.ToString()))
watch_ip.Add(p.IPAddress.ToString(), p.IPAddress);
if (!watch_scope.ContainsKey(p.ToString()))
watch_scope.Add(p.ToString(), p);
}
}
foreach (ushort port in watch_port.Keys)
{
bd.AppendFormat(@"Listen {0}", port);
bd.AppendLine();
}
if (watch_ip.Count == 0)
watch_ip.Add("127.0.0.1", new IPAddress(new byte[] { 127, 0, 0, 1 }));
foreach (KeyValuePair<string, IPPair> pair in watch_scope)
{
IPPair p = pair.Value;
if (p.IPAddress == null)
{
foreach (IPAddress add in watch_ip.Values)
{
if (!added_scope.ContainsKey(String.Format("{0}:{1}", add, p.Port)))
{
bd.AppendFormat(@"NameVirtualHost {0}:{1}", add, p.Port);
bd.AppendLine();
added_scope.Add(String.Format("{0}:{1}", add, p.Port), true);
}
}
}
else
{
if (!added_scope.ContainsKey(String.Format("{0}:{1}", p.IPAddress, p.Port)))
{
bd.AppendFormat(@"NameVirtualHost {0}:{1}", p.IPAddress, p.Port);
bd.AppendLine();
String.Format("{0}:{1}", p.IPAddress, p.Port);
}
}
}
foreach (VirtualSite site in virtualSites_)
{
site.AppendConfigSegment(bd, watch_ip.Values);
}
}
示例6: LoadTasks
public static SortedList<string, string> LoadTasks(string configPath, string cliCommandName)
{
var list = new SortedList<string, string>();
try
{
string document = File.ReadAllText(configPath);
JObject root = JObject.Parse(document);
JToken scripts = root["scripts"];
if (scripts != null)
{
var children = scripts.Children<JProperty>();
foreach (var child in children)
{
if (!list.ContainsKey(child.Name))
list.Add(child.Name, $"{cliCommandName} run {child.Name}");
}
}
bool isNpm = (cliCommandName == Constants.NPM_CLI_COMMAND);
string[] alwaysTasks = (isNpm
? Constants.NPM_ALWAYS_TASKS
: Constants.YARN_ALWAYS_TASKS);
// Only fill default tasks if any scripts are found
foreach (var reserved in alwaysTasks)
{
if (!list.ContainsKey(reserved))
list.Add(reserved, $"{cliCommandName} {reserved}");
}
AddMissingDefaultParents(list, cliCommandName, isNpm);
if (isNpm)
{
bool hasMatch = (from l in list
from t in Constants.RESTART_SCRIPT_TASKS
where l.Key == t
select l).Any();
// Add "restart" node if RESTART_SCRIPT_TASKS contains anything in list
if (hasMatch)
list.Add("restart", $"{cliCommandName} restart");
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.Write(ex);
}
return list;
}
示例7: Source_Element
/// <summary> Constructor for a new instance of the Source_Element class </summary>
public Source_Element()
: base("Source Institution", "source")
{
Repeatable = false;
possible_select_items.Add("");
clear_textbox_on_combobox_change = true;
// Get the codes to display in the source
codeToNameDictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
if (UI_ApplicationCache_Gateway.Aggregations != null )
{
SortedList<string, string> tempItemList = new SortedList<string, string>();
foreach (string thisType in UI_ApplicationCache_Gateway.Aggregations.All_Types)
{
if (thisType.IndexOf("Institution") >= 0)
{
ReadOnlyCollection<Item_Aggregation_Related_Aggregations> matchingAggr = UI_ApplicationCache_Gateway.Aggregations.Aggregations_By_Type(thisType);
foreach (Item_Aggregation_Related_Aggregations thisAggr in matchingAggr)
{
if (thisAggr.Code.Length > 1)
{
if ((thisAggr.Code[0] == 'i') || (thisAggr.Code[0] == 'I'))
{
if (!tempItemList.ContainsKey(thisAggr.Code.Substring(1)))
{
codeToNameDictionary[thisAggr.Code.Substring(1).ToUpper()] = thisAggr.Name;
tempItemList.Add(thisAggr.Code.Substring(1), thisAggr.Code.Substring(1));
}
}
else
{
if (!tempItemList.ContainsKey(thisAggr.Code))
{
codeToNameDictionary[thisAggr.Code.ToUpper()] = thisAggr.Name;
tempItemList.Add(thisAggr.Code, thisAggr.Code);
}
}
}
}
}
}
IList<string> keys = tempItemList.Keys;
foreach (string thisKey in keys)
{
possible_select_items.Add(tempItemList[thisKey].ToUpper());
if (codeToNameDictionary.ContainsKey(thisKey))
{
Add_Code_Statement_Link(thisKey, codeToNameDictionary[thisKey]);
}
}
}
}
示例8: Main
/* Pentagonal numbers are generated by the formula, Pn=n(3n-1)/2. The first ten pentagonal numbers are:
1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ...
It can be seen that P4 + P7 = 22 + 70 = 92 = P8. However, their difference, 70 22 = 48, is not pentagonal.
Find the pair of pentagonal numbers, Pj and Pk, for which their sum and difference is pentagonal and D = |Pk Pj| is minimised; what is the value of D?
*/
static void Main(string[] args)
{
int D = 0;
// Precalc some pentagonal numbers
SortedList<int, int> pentagonalNumbers = new SortedList<int, int>();
SortedList<int, int> pentagonalValues = new SortedList<int, int>(); // For fast lookup, because ContainsValue is slow on pentagonalNumbers sorted list.
int n = 1;
int pn = 1;
do
{
pentagonalNumbers.Add(n, pn);
pentagonalValues.Add(pn, pn);
n++;
pn = n * (3 * n - 1) / 2;
} while (n < 5000);
// pick pairs
bool bFound = false;
for (int jj = 2; jj < pentagonalNumbers.Count; jj++)
{
for (int kk = jj - 1; kk > 0; kk--)
{
if (pentagonalValues.ContainsKey(pentagonalNumbers[jj] + pentagonalNumbers[kk]))
{
if (pentagonalValues.ContainsKey(pentagonalNumbers[jj] - pentagonalNumbers[kk]))
{
D = Math.Abs( pentagonalNumbers[jj] - pentagonalNumbers[kk]);
bFound = true;
break;
}
}
}
if( bFound)
{
break;
}
}
Console.WriteLine(D);
Console.WriteLine("Press any key to continue");
Console.ReadLine();
}
示例9: ListProc
private void ListProc()
{
listView1.Items.Clear();
Process[] proc = System.Diagnostics.Process.GetProcesses();
List<Process> l = proc.ToList<Process>();
SortedList<String, Process> sl = new SortedList<string, Process>();
int it = 0;
foreach (Process p in proc)
{
if (sl.ContainsKey(p.ProcessName))
sl.Add(p.ProcessName + it.ToString(), p);
else sl.Add(p.ProcessName, p);
it++;
}
foreach (KeyValuePair<String, Process> pr in sl.ToList<KeyValuePair<String, Process>>())
{
ListViewItem lvi = new ListViewItem(pr.Value.ProcessName);
lvi.SubItems.Add(pr.Value.BasePriority.ToString());
lvi.SubItems.Add(pr.Value.Id.ToString());
lvi.SubItems.Add(pr.Value.WorkingSet64.ToString());
listView1.Items.Add(lvi);
}
toolStripStatusLabel1.Text = "Процессов: " + proc.Count<Process>().ToString();
int count = 0;
foreach (Process p in proc)
{
count += p.Threads.Count;
}
toolStripStatusLabel2.Text = "Потоков: " + count.ToString();
}
示例10: GetPossibleExtenders
public static SortedList<string, List<AccessPoint>> GetPossibleExtenders(CapFile[] CapFiles)
{
SortedList<string, List<AccessPoint>> AccessPoints = new SortedList<string, List<AccessPoint>>();
foreach (CapFile capFile in CapFiles)
{
SortedList<string, AccessPoint[]> PossibleExtenders = capFile.PossibleExtenders;
for (int i = 0; i < PossibleExtenders.Count; i++)
{
if (AccessPoints.ContainsKey(PossibleExtenders.Keys[i]))
{
for (int j = 0; j < PossibleExtenders.Values[i].Length; j++)
{
AccessPoint extender = PossibleExtenders.Values[i][j];
if (AccessPoints[PossibleExtenders.Keys[i]].FirstOrDefault(o => o.MacAddress == extender.MacAddress) == null)
{
AccessPoints[PossibleExtenders.Keys[i]].Add(extender);
}
}
}
else
{
AccessPoints.Add(PossibleExtenders.Keys[i], new List<AccessPoint>(PossibleExtenders.Values[i]));
}
}
}
return AccessPoints;
}
示例11: Aggregations_Element
/// <summary> Constructor for a new instance of the Aggregations_Element class </summary>
public Aggregations_Element()
: base("Aggregation", "collection")
{
Repeatable = true;
view_choices_string = String.Empty;
boxes_per_line = 3;
max_boxes = 9;
// Get the codes for the aggregation
if ((items.Count == 0) && ( UI_ApplicationCache_Gateway.Aggregations != null ))
{
SortedList<string, string> tempItemList = new SortedList<string, string>();
List<Item_Aggregation_Related_Aggregations> subcollections = UI_ApplicationCache_Gateway.Aggregations.All_Aggregations;
foreach (Item_Aggregation_Related_Aggregations thisAggr in subcollections)
{
if (!tempItemList.ContainsKey(thisAggr.Code))
{
tempItemList.Add(thisAggr.Code, thisAggr.Code);
}
}
IList<string> keys = tempItemList.Keys;
foreach (string thisKey in keys)
{
items.Add(tempItemList[thisKey].ToUpper());
}
}
}
示例12: Calc
public void Calc()
{
int thisHash = 0;
for (int b = 0; b < numBands; b++)
{
var thisSL = new SortedList<uint, List<uint>>();
for (uint s = 0; s < numSets; s++)
{
uint hashValue = 0;
for (int th = thisHash; th < thisHash + rowsPerBand; th++)
{
hashValue = unchecked(hashValue * 1174247 + minHashes[s, th]);
}
if (!thisSL.ContainsKey(hashValue))
{
thisSL.Add(hashValue, new List<uint>());
}
thisSL[hashValue].Add(s);
}
thisHash += rowsPerBand;
var copy = new SortedList<uint, List<uint>>();
foreach (uint ic in thisSL.Keys)
{
if (thisSL[ic].Count() > 1)
{
copy.Add(ic, thisSL[ic]);
}
}
lshBuckets.Add(copy);
}
}
示例13: GetNamesByPreCompile
public static string[] GetNamesByPreCompile(this string text, bool isDigit)
{
var names = text.ClearNonAlphabetChars(isDigit); //text.Split(FilteringChars, StringSplitOptions.RemoveEmptyEntries);
var preCompiledNames = new SortedList<string, string>();
foreach (var name in names)
{
if (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name)) continue;
var lowerName = name.ToLower();
foreach (var c in lowerName)
{
if (ReplaceChars.ContainsKey(c))
{
lowerName = lowerName.Replace(c, ReplaceChars[c]);
}
}
if (!preCompiledNames.ContainsKey(lowerName))
preCompiledNames.Add(lowerName, lowerName);
}
var ary = new string[preCompiledNames.Count];
preCompiledNames.Values.CopyTo(ary, 0);
return ary;
}
示例14: Main
static void Main(string[] args)
{
ulong limit = (ulong)1e8;
ulong sqr = (ulong)Math.Sqrt(limit);
ulong result = 0;
SortedList<ulong, ulong> found = new SortedList<ulong, ulong>();
for (ulong i = 1; i < sqr; i++)
{
ulong num = i+1;
ulong sqSum = i * i;
for(;;)
{
sqSum += num * num;
if (sqSum > limit)
break;
if (sqSum.IsPalindrom() && !found.ContainsKey(sqSum))
{
found.Add(sqSum, sqSum);
result += sqSum;
}
num++;
}
}
Console.WriteLine(result);
}
示例15: SetAvailableModalities
public void SetAvailableModalities(ICollection<string> modalities)
{
if (_availableModalitiesSet || modalities == null || modalities.Count == 0)
throw new InvalidOperationException(SR.ErrorCannotResetModalities);
_availableModalitiesSet = true;
SortedList<string, string> sorter = new SortedList<string, string>();
if (modalities != null)
{
foreach (string modality in modalities)
{
if (!sorter.ContainsKey(modality))
sorter.Add(modality, modality);
}
}
_availableModalities.Clear();
_availableModalities.Add(SR.ItemClear);
_availableModalities.AddRange(sorter.Keys);
_modalityPicker.Items.Clear();
_modalityPicker.Items.AddRange(_availableModalities.ToArray());
this.CheckedModalities = new List<string>();
}