Best performance on a String Dictionary in C# -
i designing c# class contains string hierarchy, each string has 0 or 1 parents.
my inclination implement dictionary<string,string> key child , value parent. dictionary may have large amount of values, can't exact size. seems should perform faster creating composite wrapper references parent, wrong.
is there alternative approach can take ensure better performance speed?
retrieving values dictionary<k,v> extremely fast (close o(1), i.e., constant time lookup regardless of size of collection) because underlying implementation uses hash table. of course, if key type uses terrible hashing algorithm performance can degrade, can rest assured not case framework's string type.
however, asked in comment, need answer few questions:
- define performance metric important, i.e., time (cpu) or space (memory).
- what requirements? how used? what's worst case scenario? going hold ton of data relatively infrequent lookups, many lookups need performed in short amount of time, or both hold true?
the dictionary<k,v> class uses array internally grow add items. okay you? again, need more specific in terms of requirements before can give complete answer.
Comments
Post a Comment