I'm using a lot of dictionary collections that contain other dictionary collections like:
Dictionary<Guid, List<string>>()
Dictionary<Guid, Dictionary<Guid, List<string>>>()
I'm looping through these maps, and passing them around in parameters in my code.
This seems like a bad idea since you can't really extend the nature of these collections now.
Should I wrap these around in a class?
A dictionary can contain dictionaries, this is called nested dictionaries.
Creating a Nested Dictionary In Python, a Nested dictionary can be created by placing the comma-separated dictionaries enclosed within braces.
But the key values of the dictionary contain different types of values that don't need to maintain any order. When one or more dictionaries are declared inside another dictionary then it is called a nested dictionary or dictionaries of the dictionary.
Do you run into such limitations? Is your program hard to alter/debug? If so, refactor. Otherwise, profit: you're a pragmatic programmer,.
That said, I can see room for immediate improvement:
IDictionary<Guid, List<string>> x;
IDictionary<Guid, IDictionary<Guid, List<string>> y = new Dictionary<Guid, IDictionary<Guid, List<string>>();
I'd say yes, create a class specifically for it. Then you can add/not-implement methods as per your usage, rather than working around any limitations you find with Dictionary
with your usage.
It sounds like you'd want a tree-like structure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With