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)
[C++ to C#] mapT*, S
Quote:Original post by arithmaWhat 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 TelastynQuote:Original post by arithmaWhat 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?
Quote:Original post by arithmaQuote:Original post by TelastynQuote:Original post by arithmaWhat 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?
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement