本文整理汇总了C#中OrderedDictionary.Add方法的典型用法代码示例。如果您正苦于以下问题:C# OrderedDictionary.Add方法的具体用法?C# OrderedDictionary.Add怎么用?C# OrderedDictionary.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderedDictionary
的用法示例。
在下文中一共展示了OrderedDictionary.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TokenParser
public TokenParser()
{
_tokens = new OrderedDictionary<Tokens, string>();
_regExMatchCollection = new OrderedDictionary<Tokens, MatchCollection>();
_index = 0;
_inputString = string.Empty;
_customFunctionIndex = 100;
_tokens.Add(Tokens.Whitespace, "[ \\t]+");
_tokens.Add(Tokens.Newline, "[\\r\\n]+");
_tokens.Add(Tokens.Function, "func([a-zA-Z_][a-zA-Z0-9_]*)\\(((?<BR>\\()|(?<-BR>\\))|[^()]*)+\\)");
_tokens.Add(Tokens.LogN, "[Ll][Oo][Gg][Nn]\\(((?<BR>\\()|(?<-BR>\\))|[^()]*)+\\)");
_tokens.Add(Tokens.Sqrt, "[Ss][Qq][Rr][Tt]\\(((?<BR>\\()|(?<-BR>\\))|[^()]*)+\\)");
_tokens.Add(Tokens.Sin, "[Ss][Ii][Nn]\\(((?<BR>\\()|(?<-BR>\\))|[^()]*)+\\)");
_tokens.Add(Tokens.Cos, "[Cc][Oo][Ss]\\(((?<BR>\\()|(?<-BR>\\))|[^()]*)+\\)");
_tokens.Add(Tokens.Tan, "[Tt][Aa][Nn]\\(((?<BR>\\()|(?<-BR>\\))|[^()]*)+\\)");
_tokens.Add(Tokens.Abs, "[Aa][Bb][Ss]\\(((?<BR>\\()|(?<-BR>\\))|[^()]*)+\\)");
_tokens.Add(Tokens.Log, "[Ll][Oo][Gg]\\(((?<BR>\\()|(?<-BR>\\))|[^()]*)+\\)");
_tokens.Add(Tokens.Variable, "[a-zA-Z_][a-zA-Z0-9_]*");
_tokens.Add(Tokens.Float, "([0-9]+)?\\.+[0-9]+");
_tokens.Add(Tokens.Integer, "[0-9]+");
_tokens.Add(Tokens.Lparen, "\\(");
_tokens.Add(Tokens.Rparen, "\\)");
_tokens.Add(Tokens.Exponent, "\\^");
_tokens.Add(Tokens.Modulus, "\\%");
_tokens.Add(Tokens.Multiply, "\\*");
_tokens.Add(Tokens.Divide, "\\/");
_tokens.Add(Tokens.Add, "\\+");
_tokens.Add(Tokens.Subtract, "\\-");
}
示例2: LoadObjectLayers
public Layer[] LoadObjectLayers(TmxMap tmxMap, ContentManager content)
{
var layers = new Layer[tmxMap.ObjectGroups.Count];
for (int i = 0; i < tmxMap.ObjectGroups.Count; i++)
{
OrderedDictionary<string, IGameObject> _gameObjects = new OrderedDictionary<string, IGameObject>();
foreach (var tmxObject in tmxMap.ObjectGroups[i].Objects)
{
if (tmxObject.Type == "Particle Emitter")
{
IGameObject gameObject = this.LoadParticleEmitter(tmxObject, content);
_gameObjects.Add(tmxObject.Name, gameObject);
}
else if (tmxObject.Type == "NPC Spawner")
{
IGameObject gameObject = this.LoadNpcSpawner(tmxObject, _gameObjects, content);
_gameObjects.Add(tmxObject.Name, gameObject);
}
}
layers[i] = new Layer(_gameObjects, tmxMap.ObjectGroups[i].ZOrder);
}
return layers;
}
示例3: AppendItem
public void AppendItem()
{
OrderedDictionary<string, string> dictionary = new OrderedDictionary<string, string>();
dictionary.Add("1", "one");
dictionary.Add("2", "two");
Assert.AreEqual(2, dictionary.Count);
}
示例4: Add
public void Add()
{
var dict = new OrderedDictionary<string, int>();
dict.Add("1", 2);
dict.Add("2", 3);
Assert.AreEqual(dict[0], 2);
Assert.AreEqual(dict[1], 3);
}
示例5: Before
public void Before() {
_random = new Random();
_dict = new OrderedDictionary();
for (int i = 0; i < n; i++) {
_dict.Add(i, new Entity(CP.NumComponents, null));
}
}
示例6: Main
static void Main(string[] args)
{
OrderedDictionary<string, SortedSet<Person>> coursesAndStudents = new OrderedDictionary<string, SortedSet<Person>>();
while (true)
{
string[] input = Console.ReadLine().Split(new[] { ' ', '|' }, StringSplitOptions.RemoveEmptyEntries);
string course = input[2].Trim();
string firstName = input[0].Trim();
string lastName = input[1].Trim();
if (coursesAndStudents.ContainsKey(course))
{
coursesAndStudents[course].Add(new Person(firstName, lastName));
}
else
{
SortedSet<Person> set = new SortedSet<Person>();
set.Add(new Person(firstName, lastName));
coursesAndStudents.Add(course, set);
}
Output(coursesAndStudents);
}
}
示例7: RemoveNumbersThatOccurOddNumbers
public static string RemoveNumbersThatOccurOddNumbers(int[] input)
{
HashSet<int> whiteList = new HashSet<int>();
var uniqueValuesInList = new OrderedDictionary<int, int>();
foreach (var item in input)
{
if (uniqueValuesInList.ContainsKey(item))
{
uniqueValuesInList[item]++;
}
else
{
uniqueValuesInList.Add(item, 1);
}
}
string result = null;
foreach (var item in uniqueValuesInList)
{
if (item.Value >= (uniqueValuesInList.Count / 2) + 1)
{
result = string.Format("Majorant number is {0}.", item.Key);
}
}
if (result == null)
{
result = "Does not exist majorant number.";
}
return result;
}
示例8: Before
public void Before() {
_dict = new OrderedDictionary();
_lookup = new Entity[n];
for (int i = 0; i < n; i++) {
var e = new Entity(CP.NumComponents);
_dict.Add(i, e);
_lookup[i] = e;
}
}
示例9: Tokenize
public IDictionary<string, double> Tokenize(string line)
{
OrderedDictionary<string, double> res = new OrderedDictionary<string, double>();
foreach (string elt in line.Split(' '))
if (res.ContainsKey(elt))
res[elt]++;
else
res.Add(elt, 1);
return res;
}
示例10: Start
// Use this for initialization
void Start () {
UserProfile user = new UserProfile("MyName", "[email protected]", "password");
OrderedDictionary orderedBook = new OrderedDictionary();
orderedBook.Add(user.Name, user);
if (orderedBook.Contains("MyName"))
{
Debug.Log("Found key");
}
}
示例11: Main
static void Main(string[] args)
{
const string fileName = "students.txt";
string input = Console.ReadLine();
using (StreamWriter newWriter = File.AppendText(fileName))
{
while (input != "end")
{
newWriter.WriteLine(input);
input = Console.ReadLine();
}
}
var dataStorage = new OrderedDictionary<string, OrderedDictionary<string, Person>>();
using (var streamReader = new StreamReader(fileName))
{
string currentLine;
while ((currentLine = streamReader.ReadLine()) != null)
{
string[] parameters = currentLine.Split(new char[] { ' ', '|' }, StringSplitOptions.RemoveEmptyEntries);
string firstName = parameters[0];
string lastName = parameters[1];
string course = parameters[2];
if (!dataStorage.ContainsKey(course))
{
dataStorage.Add(course, new OrderedDictionary<string, Person>());
}
if (!dataStorage[course].ContainsKey(lastName))
{
dataStorage[course].Add(lastName, new Person(firstName, lastName));
}
}
}
foreach (var course in dataStorage)
{
Console.Write($"{course.Key} -> ");
string peopleInCourse = "";
foreach (var person in course.Value)
{
peopleInCourse += ", " + person.Value.ToString();
}
peopleInCourse = peopleInCourse.Remove(0, 2);
Console.WriteLine(peopleInCourse);
}
}
示例12: FormView1_ItemInserting1
protected void FormView1_ItemInserting1(object sender, FormViewInsertEventArgs e)
{
FormView fv = (FormView)sender;
string filename = @"E:\Projects\IGRSS\FINAL\WebApp\Inspection\InspectionCheckList.xml";
OrderedDictionary coll = new OrderedDictionary();
XmlDocument doc = new XmlDocument();
doc.Load(filename);
foreach (XmlNode Node in doc.SelectNodes("DocumentElement/Items"))
{
TextBox txt = (TextBox)fv.FindControl("txt" + Node.Attributes["ItemId"].InnerText);
CheckBox chk = (CheckBox)fv.FindControl("chk" + Node.Attributes["ItemId"].Value);
coll.Add(txt.ID, txt.Text);
coll.Add(chk.ID, chk.Checked);
}
e.Values.Add("Values", coll);
}
示例13: Main
public static void Main()
{
OrderedDictionary<double, Product> products = new OrderedDictionary<double, Product>();
for (int i = 0; i < 500000; i++)
{
var currPrice = 100 + i;
products.Add(currPrice, new Product("Pesho" + i, currPrice));
}
// Wait 2-3 seconds.
Console.WriteLine(products.Range(120, true, 1040, true));
}
示例14: Main
static void Main(string[] args)
{
OrderedDictionary holder = new OrderedDictionary();
Console.WriteLine("Please enter your name:");
holder.Add("First_Name", Console.ReadLine());
Console.WriteLine("Please enter your middle name:");
holder.Add("Middle_Name", Console.ReadLine());
Console.WriteLine("Please enter your last name:");
holder.Add("Last_Name", Console.ReadLine());
Console.WriteLine("Balance:");
decimal balance = Convert.ToDecimal(Console.ReadLine());
Console.WriteLine("IBAN:");
ulong IBAN = Convert.ToUInt64(Console.ReadLine());
Console.WriteLine("Bank name:");
String bankName = Console.ReadLine(); ;
OrderedDictionary creditCard = new OrderedDictionary();
Console.WriteLine("First Bank Account:");
creditCard.Add("Account1", Console.ReadLine());
Console.WriteLine("Second Bank Account:");
creditCard.Add("Account2", Console.ReadLine());
Console.WriteLine("Third Bank Account:");
creditCard.Add("Account3", Console.ReadLine());
}
示例15: Quanta
public static OrderedDictionary<String, Object> Quanta(this Object obj)
{
if (obj == null) return null;
var schema = new OrderedDictionary<String, Object>();
var props = obj.GetType().GetProperties(BF.PublicInstance).Where(p => p.HasAttr<QuantumAttribute>()).ToReadOnly();
props.ForEach((p, i) =>
{
var v = p.GetValue(obj, null);
var @default = p.PropertyType.Fluent(t => t.IsValueType ? Activator.CreateInstance(t) : null);
if (!Equals(v, @default)) schema.Add(p.Attr<QuantumAttribute>().Signature, v);
});
return schema;
}