- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Difference between a PairedListDictionary and a regular Dictionary
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- Difference between a PairedListDictionary and a regular Dictionary
Replies: 3 (Who?), Viewed: 458 times.
#1
3rd Feb 2021 at 2:56 PM
Posts: 3,856
Thanks: 8484 in 67 Posts
Difference between a PairedListDictionary and a regular Dictionary
Heya!It's actually quite an easy question; what exactly is the difference between C#'s dictionary and EA's PairedListDictionary?
All I can get out of it is that the keyvaluepair is easier to access? But even that's just a theory. So was just wondering if anyone else knows!
Advertisement
#2
3rd Feb 2021 at 4:06 PM
Posts: 437
Thanks: 5285 in 22 Posts
Quote: Originally posted by Lyralei
Heya! It's actually quite an easy question; what exactly is the difference between C#'s dictionary and EA's PairedListDictionary? All I can get out of it is that the keyvaluepair is easier to access? But even that's just a theory. So was just wondering if anyone else knows! |
C#'s generic dictionaries are implemented using hash tables, whereas the PairedListDictionary appears to just be an association list. In practice, the two would be functionally equivalent for most cases, but if you're doing a lot of searching or deleting, C# dictionaries will be faster on average. Plus, it uses generics, so you don't have the hassle of boxing to/unboxing from object like you would with a PairedListDictionary.
"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
#3
4th Feb 2021 at 10:33 AM
Posts: 3,856
Thanks: 8484 in 67 Posts
Quote: Originally posted by gamefreak130
C#'s generic dictionaries are implemented using hash tables, whereas the PairedListDictionary appears to just be an association list. In practice, the two would be functionally equivalent for most cases, but if you're doing a lot of searching or deleting, C# dictionaries will be faster on average. Plus, it uses generics, so you don't have the hassle of boxing to/unboxing from object like you would with a PairedListDictionary. |
Anyways! Thanks for the explanation! It does really help! Difference I noticed as well is that PairedListDictionary has the concept of ContainKey() but when it comes to the value, it's trying to get the value, rather than being able to see if it 'contains' the value. Which is an interesting design choice IMO.
#4
5th Feb 2021 at 11:26 PM
Posts: 768
Thanks: 8144 in 12 Posts
From what I can see the PairedListDictionary is sprinkled all over the source code.
The only reason I can see to use it is that the EA implementation keeps it's internal order of elements while the normal Dictionary doesn't guarantee for it but often "happens" to be in the order you expect.
Or perhaps Mono's inplementation was flawed at the time they started development? In the older code you often see them using arrays and hashtables instead of lists and dictionaries.
The only reason I can see to use it is that the EA implementation keeps it's internal order of elements while the normal Dictionary doesn't guarantee for it but often "happens" to be in the order you expect.
Or perhaps Mono's inplementation was flawed at the time they started development? In the older code you often see them using arrays and hashtables instead of lists and dictionaries.
Who Posted
|