I am new to C# and I want to understand what is the memory and time overhead of using Dictionary.Values
property. Here I could find nothing about the algorithm time complexity specifications or about memory complexity? Am I looking at wrong place or is it undefined in C# spec?
P.S. I am coming from C++ bg.
is it undefined in C# spec?
It isn't defined in the C# spec because this isn't a C# feature - it is a framework implementation detail.
.Values
is lazily instantiated once the first time it is requested; after that, the existing value is handed out. So yes, some memory might be allocated when it is first used. However, it doesn't contain a snapshot copy of the values, so : this isn't an
expensive allocation. It simply contains a reference back to the parent dictionary instance.
private Dictionary<TKey, TValue> dictionary;
is literally the only field in ValueCollection<TKey, TValue>
. It is essentially a facade that provides a value-centric view over the same data.
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