[C++ to C#] mapT*, S

Started by
5 comments, last by Agony 17 years ago

What is the type std::map<T*, S> mapped from the C++ language into in the C# language?
for any real types of T and S (eg. T is int and S is char)
[ my blog ]
Advertisement
Quote:Original post by arithma
What is the type std::map<T*, S> mapped from the C++ language into in the C# language?for any real types of T and S (eg. T is int and S is char)


Dictionary<T,S> assuming .NET 2.0 or better.
Quote:Original post by Telastyn
Quote:Original post by arithma
What is the type std::map<T*, S> mapped from the C++ language into in the C# language?for any real types of T and S (eg. T is int and S is char)


Dictionary<T,S> assuming .NET 2.0 or better.


How is the equality handled (how do you specify that the comparison should be made based on the contents or on the reference itself?)

How sure are you of your answer?
[ my blog ]
Quote:Original post by arithma
Quote:Original post by Telastyn
Quote:Original post by arithma
What is the type std::map<T*, S> mapped from the C++ language into in the C# language?for any real types of T and S (eg. T is int and S is char)


Dictionary<T,S> assuming .NET 2.0 or better.


How is the equality handled (how do you specify that the comparison should be made based on the contents or on the reference itself?)

How sure are you of your answer?

Dictionary is using hashing so while it offers the same functionality as std::map it doesn't offer the same complexity. A closer match would be SortedDictionary or SortedList and it uses the IComparer interface for comparison.
Correct me if am wrong, but when map<int*, char> is used, the comparison is done on the pointers themselves rather than the integer values. I believe the comparisons in the .NET Framework are done on the values referenced by the references?
[ my blog ]
Yeah I think that is accurate.
Steven ToveySPUify | Twitter
Perhaps you could create a small generic class or struct that implements IComparable, and simply holds a reference to the actual object. The implementation of IComparable would specifically do a ReferenceEquals() comparison. Then you could use that as the key for your container.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke

This topic is closed to new replies.

Advertisement