本文整理汇总了C#中MultiDictionary类的典型用法代码示例。如果您正苦于以下问题:C# MultiDictionary类的具体用法?C# MultiDictionary怎么用?C# MultiDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultiDictionary类属于命名空间,在下文中一共展示了MultiDictionary类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Remove
public void Remove()
{
MultiDictionary<string, string> dictionary = new MultiDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
dictionary.Add("x", "x1");
dictionary.Add("x", "x2");
dictionary.Add("y", "y1");
Assert.Equal(true, dictionary.Remove("x", "x1"));
Assert.Equal(2, dictionary.KeyCount);
Assert.Equal(2, dictionary.ValueCount);
Assert.Equal(true, dictionary.Remove("x", "x2"));
Assert.Equal(1, dictionary.KeyCount);
Assert.Equal(1, dictionary.ValueCount);
Assert.Equal(true, dictionary.Remove("y", "y1"));
Assert.Equal(0, dictionary.KeyCount);
Assert.Equal(0, dictionary.ValueCount);
dictionary.Add("x", "x1");
dictionary.Add("x", "x2");
Assert.Equal(true, dictionary.Remove("x", "x2"));
Assert.Equal(1, dictionary.KeyCount);
Assert.Equal(1, dictionary.ValueCount);
}
开发者ID:cameron314,项目名称:msbuild,代码行数:31,代码来源:MultiDictionary_Tests.cs
示例2: ImmutableConstantChecker
private readonly MultiDictionary<ISentenceForm, Fact> _sentencesByForm; //TODO: Immutable
#endregion Fields
#region Constructors
private ImmutableConstantChecker(ImmutableSentenceFormModel sentenceModel, MultiDictionary<ISentenceForm, Fact> sentencesByForm)
{
Debug.Assert(sentenceModel.ConstantSentenceForms.IsSupersetOf(sentencesByForm.Keys));
_sentenceModel = sentenceModel;
_sentencesByForm = sentencesByForm;
_allSentences = sentencesByForm.SelectMany(s => s.Value).ToImmutableHashSet();
}
开发者ID:druzil,项目名称:nggp-base,代码行数:13,代码来源:ImmutableConstantChecker.cs
示例3: Main
static void Main()
{
PhoneBookByName = new MultiDictionary<string, Entry>(true);
PhoneBookByNameAndTown = new MultiDictionary<Tuple<string, string>, Entry>(true);
using (StreamReader phonesReader = new StreamReader(@"../../Phones.txt"))
{
string phoneInfo = phonesReader.ReadLine();
while (phoneInfo != null)
{
ParsePhoneInfo(phoneInfo);
phoneInfo = phonesReader.ReadLine();
}
}
using (StreamReader commandsReader = new StreamReader(@"../../commands.txt"))
{
string command = commandsReader.ReadLine();
while (command != null)
{
List<Entry> enriesFound = ExecuteCommand(command);
// warning printing can take a long time
// PrintEntries(command, enriesFound);
// Console.ReadLine();
command = commandsReader.ReadLine();
}
}
}
开发者ID:bahtev,项目名称:TelerikAcademy,代码行数:31,代码来源:Phonebook.cs
示例4: ReadContactsFromFile
private static void ReadContactsFromFile(string file, MultiDictionary<string, string> contactsName, MultiDictionary<string, string> contactsTown)
{
StreamReader reader = new StreamReader(file);
string line = reader.ReadLine();
using (reader)
{
while (line != null)
{
var details = line.Split('|');
string names = details[0].Trim();
string town = details[1].Trim();
string phone = details[2].Trim();
contactsTown.Add(town, phone);
var namesSeparated = names.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var name in namesSeparated)
{
contactsName.Add(name, phone);
}
line = reader.ReadLine();
}
}
}
开发者ID:huuuskyyy,项目名称:CSharp-Homeworks,代码行数:27,代码来源:Program.cs
示例5: CreateTypeParameterMap
private MultiDictionary<string, TypeParameterSymbol> CreateTypeParameterMap()
{
var map = new MultiDictionary<string, TypeParameterSymbol>();
switch (_crefSyntax.Kind())
{
case SyntaxKind.TypeCref:
{
AddTypeParameters(((TypeCrefSyntax)_crefSyntax).Type, map);
break;
}
case SyntaxKind.QualifiedCref:
{
QualifiedCrefSyntax qualifiedCrefSyntax = ((QualifiedCrefSyntax)_crefSyntax);
AddTypeParameters(qualifiedCrefSyntax.Member, map);
AddTypeParameters(qualifiedCrefSyntax.Container, map);
break;
}
case SyntaxKind.NameMemberCref:
case SyntaxKind.IndexerMemberCref:
case SyntaxKind.OperatorMemberCref:
case SyntaxKind.ConversionOperatorMemberCref:
{
AddTypeParameters((MemberCrefSyntax)_crefSyntax, map);
break;
}
default:
{
throw ExceptionUtilities.UnexpectedValue(_crefSyntax.Kind());
}
}
return map;
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:33,代码来源:WithCrefTypeParametersBinder.cs
示例6: AddEvent
private static void AddEvent(string command)
{
var currentEvent = new Event(DateTime.Now, "title", "location");
///GetParameters(command, "AddEvent", out date, out title, out location);
var events = new MultiDictionary<string, Event>(true); ///added that to make it stop crashing too
events.Add("title", currentEvent);
}
开发者ID:Alex-Bubblemaster,项目名称:HighQualityCode,代码行数:7,代码来源:EventHandlingProgramme.cs
示例7: AddTypeParameters
private void AddTypeParameters(TypeSyntax typeSyntax, MultiDictionary<string, TypeParameterSymbol> map)
{
switch (typeSyntax.Kind())
{
case SyntaxKind.AliasQualifiedName:
AddTypeParameters(((AliasQualifiedNameSyntax)typeSyntax).Name, map);
break;
case SyntaxKind.QualifiedName:
// NOTE: Dev11 does not warn about duplication, it just matches parameter types to the
// *last* type parameter with the same name. That's why we're iterating backwards.
QualifiedNameSyntax qualifiedNameSyntax = (QualifiedNameSyntax)typeSyntax;
AddTypeParameters(qualifiedNameSyntax.Right, map);
AddTypeParameters(qualifiedNameSyntax.Left, map);
break;
case SyntaxKind.GenericName:
AddTypeParameters((GenericNameSyntax)typeSyntax, map);
break;
case SyntaxKind.IdentifierName:
case SyntaxKind.PredefinedType:
break;
default:
Debug.Assert(false, "Unexpected type syntax kind " + typeSyntax.Kind());
break;
}
}
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:25,代码来源:WithCrefTypeParametersBinder.cs
示例8: WithPrimaryConstructorParametersBinder
internal WithPrimaryConstructorParametersBinder(MethodSymbol primaryCtor, Binder next)
: base(next)
{
Debug.Assert((object)primaryCtor != null);
this.primaryCtor = primaryCtor;
var parameters = primaryCtor.Parameters;
var definitionMap = new SmallDictionary<string, ParameterSymbol>();
for (int i = parameters.Length - 1; i >= 0; i--)
{
var parameter = parameters[i];
definitionMap[parameter.Name] = parameter;
}
this.definitionMap = definitionMap;
var parameterMap = new MultiDictionary<string, ParameterSymbol>(parameters.Length, EqualityComparer<string>.Default);
foreach (var parameter in parameters)
{
parameterMap.Add(parameter.Name, parameter);
}
this.parameterMap = parameterMap;
}
开发者ID:afrog33k,项目名称:csnative,代码行数:26,代码来源:WithPrimaryConstructorParametersBinder.cs
示例9: IndexedArgInstances
public IndexedArgInstances(List<ArgInstance> instances)
{
_mandatoryFullNames = new HashSet<string>();
_argInstancesByName = new MultiDictionary<string, ArgInstance>();
HashSet<string> tempNames = new HashSet<string>();
foreach (ArgInstance currentInstance in instances)
{
if (currentInstance.Arg.IsMandatory)
{
_mandatoryFullNames.Add(currentInstance.FullName);
}
tempNames.Clear();
tempNames.Add(currentInstance.Name);
tempNames.Add(currentInstance.FullName);
if (currentInstance.ShortName != null)
{
tempNames.Add(currentInstance.ShortName);
}
foreach (string name in tempNames)
{
_argInstancesByName.Add(name, currentInstance);
}
}
}
开发者ID:ruibm,项目名称:Danio,代码行数:26,代码来源:IndexedArgInstances.cs
示例10: CreateTypeParameterMap
private MultiDictionary<string, TypeParameterSymbol> CreateTypeParameterMap()
{
var map = new MultiDictionary<string, TypeParameterSymbol>();
switch (_crefSyntax.Kind())
{
case SyntaxKind.TypeCref:
{
AddTypeParameters(((TypeCrefSyntax)_crefSyntax).Type, map);
break;
}
case SyntaxKind.QualifiedCref:
{
QualifiedCrefSyntax qualifiedCrefSyntax = ((QualifiedCrefSyntax)_crefSyntax);
AddTypeParameters(qualifiedCrefSyntax.Member, map);
AddTypeParameters(qualifiedCrefSyntax.Container, map);
break;
}
case SyntaxKind.NameMemberCref:
case SyntaxKind.IndexerMemberCref:
case SyntaxKind.OperatorMemberCref:
case SyntaxKind.ConversionOperatorMemberCref:
{
AddTypeParameters((MemberCrefSyntax)_crefSyntax, map);
break;
}
default:
{
Debug.Assert(false, "Unexpected cref syntax kind " + _crefSyntax.Kind());
break;
}
}
return map;
}
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:34,代码来源:WithCrefTypeParametersBinder.cs
示例11: PhonebookRepository
public PhonebookRepository()
{
this.dictByFirstName = new MultiDictionary<string, PhonebookEntry>(true);
this.dictByMiddleName = new MultiDictionary<string, PhonebookEntry>(true);
this.dictByLastName = new MultiDictionary<string, PhonebookEntry>(true);
this.dictByNickname = new MultiDictionary<string, PhonebookEntry>(true);
}
开发者ID:elibk,项目名称:DSA,代码行数:7,代码来源:PhonebookRepository.cs
示例12: Phonebook
public Phonebook()
{
this.byFirstName = new MultiDictionary<string, PhonebookEntry>(AllowDuplicates);
this.byMiddleName = new MultiDictionary<string, PhonebookEntry>(AllowDuplicates);
this.byLastName = new MultiDictionary<string, PhonebookEntry>(AllowDuplicates);
this.byNickname = new MultiDictionary<string, PhonebookEntry>(AllowDuplicates);
}
开发者ID:vladislav-karamfilov,项目名称:TelerikAcademy,代码行数:7,代码来源:Phonebook.cs
示例13: GenerateSourceNodes
// generate nodes for symbols that share the same name, and all their descendants
private static void GenerateSourceNodes(
string name,
int parentIndex,
MultiDictionary<string, ISymbol>.ValueSet symbolsWithSameName,
List<Node> list,
Action<ISymbol, MultiDictionary<string, ISymbol>> lookup)
{
var node = new Node(name, parentIndex);
var nodeIndex = list.Count;
list.Add(node);
var symbolMap = AllocateSymbolMap();
try
{
// Add all child members
foreach (var symbol in symbolsWithSameName)
{
lookup(symbol, symbolMap);
}
foreach (var kvp in symbolMap)
{
GenerateSourceNodes(kvp.Key, nodeIndex, kvp.Value, list, lookup);
}
}
finally
{
FreeSymbolMap(symbolMap);
}
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:31,代码来源:SymbolTreeInfo_Source.cs
示例14: Catalog
public Catalog()
{
this.name = new MultiDictionary<string, Content>(true);
this.price = new OrderedBag<Content>();
this.producer = new MultiDictionary<string, Content>(true);
this.nameAndProducer = new MultiDictionary<Tuple<string, string>, Content>(true);
}
开发者ID:kikooo52,项目名称:TelerikAkademy,代码行数:7,代码来源:Catalog.cs
示例15: PhoneBook
public PhoneBook()
{
this.FirstNames = new MultiDictionary<string, Record>(true);
this.MiddleNames = new MultiDictionary<string, Record>(true);
this.LastNames = new MultiDictionary<string, Record>(true);
this.Towns = new MultiDictionary<string, Record>(true);
}
开发者ID:Varbanov,项目名称:TelerikAcademy,代码行数:7,代码来源:PhoneBook.cs
示例16: ShoppingCenter
public ShoppingCenter()
{
productsByName = new MultiDictionary<string, Product>(true);
nameAndProducer = new MultiDictionary<string, Product>(true);
productsByPrice = new OrderedMultiDictionary<decimal, Product>(true);
productsByProducer = new MultiDictionary<string, Product>(true);
}
开发者ID:ekostadinov,项目名称:CoursesProjects,代码行数:7,代码来源:ShoppingCenter.cs
示例17: Main
static void Main()
{
#if DEBUG
Console.SetIn(new System.IO.StreamReader("../../input.txt"));
#endif
var input = Console.ReadLine();
// Task 4
var set = new MultiDictionary<char, int>(true);
for (int i = 0; i < input.Length; i++)
set[input[i]].Add(i);
var result = Factorial(input.Length);
foreach (var pair in set)
result /= Factorial(pair.Value.Count);
// Catalan Numbers
int n = input.Length;
double number = 1;
for (int i = 2; i <= n; i++)
number *= (4 * i - 2) / (1.0 + i);
Console.WriteLine((BigInteger)number * result);
}
开发者ID:dgrigorov,项目名称:TelerikAcademy-1,代码行数:28,代码来源:Program.cs
示例18: PhoneBook
public PhoneBook(List<PhoneRecord> phoneRecords)
{
names = new MultiDictionary<string, PhoneRecord>(true);
towns = new MultiDictionary<string, PhoneRecord>(true);
phones = new MultiDictionary<string, PhoneRecord>(true);
FillLists(phoneRecords);
}
开发者ID:VyaraGGeorgieva,项目名称:TelerikAcademy,代码行数:8,代码来源:PhoneBook.cs
示例19: FastInvokerBase
protected FastInvokerBase(Type type)
{
ObjectType = type;
MethodNameCache = new MultiDictionary<string, MethodInfo>(false);
type.GetMethods(_methodBindingFlags).Each(method => MethodNameCache.Add(method.Name, method));
}
开发者ID:xliang,项目名称:Magnum,代码行数:8,代码来源:FastInvokerBase.cs
示例20: ListEvents
private static void ListEvents(string command)
{
int pipeIndex = command.IndexOf('|');
var events = new MultiDictionary<string, Event>(true); /// added that to make it stop crashing too
DateTime date = GetDate(command, "ListEvents");
string countString = command.Substring(pipeIndex + 1);
int count = int.Parse(countString); /// events.ListEvents(date,count); commented that to make it build
}
开发者ID:Alex-Bubblemaster,项目名称:HighQualityCode,代码行数:8,代码来源:EventHandlingProgramme.cs
注:本文中的MultiDictionary类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论