本文整理汇总了C#中MultiDictionary类的典型用法代码示例。如果您正苦于以下问题:C# MultiDictionary类的具体用法?C# MultiDictionary怎么用?C# MultiDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultiDictionary类属于命名空间,在下文中一共展示了MultiDictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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();
}
示例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();
}
}
}
示例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();
}
}
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}