Is there a bijective dictionary in .NET that efficiently stores Key / Values pairs where both keys and values are different, so is bijective mapping possible (i.e. TryGetValue / TryGetKey)? A naive approach would be to have two internal dictionaries: a key value and a dictionary with a value key, but this is not memory efficient.
I do not believe in .NET. Depending on the types of keys / values, I am not sure that using two dictionaries is likely to result in a significant loss of efficiency: this is what I would do until I saw a problem based on the fact that it is simple.
, , . , ...
EDIT: :
, 2 , . , . , . , .
HashSet / HashSet
? 64 , ( ). , .
, , , Dictionary.
"" .
var source = GetSomeDictionary(); var opposite = source.ToDictionary(x => x.Value, x => x.Key)
, , ... , . : .
But, most likely, you can hold the second dictionary - and want to save time.
Source: https://habr.com/ru/post/1703577/More articles:How to navigate multiple relationships using LINQ to Entities? - linqThe interaction between httpmodules and httphandlers - asp.netStrange ListView selection behavior on Android - androidJapanese / Chinese data in SQL Server table - unicodeUsing ProxyPass for pages but not images - apacheAJAX update panel swallows exceptions and strange behavior - ajaxSvn Turtle Client Creation Report - svnWCF / Silverlight / SQL Caching Strategies - cachingIs it possible to get the current line number when parsing an XML document using Xerces? - javaPress space bar with indentation - htmlAll Articles