Jump to content
  • Advertisement
Sign in to follow this  
arithma

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

This topic is 4181 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!