c# - Is there a built in type for a lookup/reverse lookup table? -
this question has answer here:
- bidirectional 1 1 dictionary in c# 8 answers
i'm trying implement baudot character encoding. right now, i'm using 2 dictionaries mirrors of each other:
dictionary<char, int> lookup = new dictionary<char, int> { { ' ', 0x100100 }, { '-', 0x011000 }, { '/', 0x010111 }, { '0', 0x001101 }, { '1', 0x011101 }, ... }; dictionary<int, char> reverse = new dictionary<int, char> { { 0x100100, ' ' }, { 0x011000, '-' }, { 0x010111, '/' }, { 0x001101, '0' }, { 0x011101, '1' }, ... };
is there built in type handles already? like:
var lookup = new lookup<int, char>(); lookup.getbykey(0x100100); lookup.getbyvalue('c');
i couldn't find when searched 'reverse lookup' or 'lookup table', seemed related dns or linqtosql.
(i'm using baudot because it's necessary cospas sarsat devices)
i think in need of bi-directional
dictionary. there many such implementations available. 1 in link though :
http://blogs.microsoft.co.il/blogs/ranw/bdirectional.txt
the pre-requisite being key , value should not of same type, in case applies.
Comments
Post a Comment