tags:

views:

1200

answers:

5

Does anyone have information or example of how to mount the equivalent of a Dictionary (VB6) in C or C++ ?
This implementation is used to be passed as a parameter called DLL VB6.

My intention is to create a Dictionary in C (win32 using VARIANT/ARRAYs, etc) and pass it to call a VB. So I have to learn how to create this data structure.

Tanks.

+9  A: 

How about a map?

scottm
+3  A: 

You mean besides std::map in the map header?

Rob Kennedy
+5  A: 

Dictionary is hash based, map is a tree based container. I think tr1 added a hash container of some sort but on a lot of platforms you can use hash_map

Hippiehunter
+6  A: 

The next version of C++ will have unordered_map<> (apparently they thought that calling it hash_map would conflict with too many independent implementations), which will be a hash-based container.

It was added to Boost, and is likely to be in TR1. As always, if your development system doesn't support the new standard features, I recommend Boost.

David Thornley
+2  A: 

A hash table? You can find several existing hash table packages in C, for instance:

You can also use a package made for permanent storage, since some have an option to keep everything in memory for speed.

  • HamsterDB "in memory database", option HAM_IN_MEMORY_DB
  • BerkeleyDB, may be by switching buffering off or specifying no file ("In-memory databases never intended to be preserved on disk may be created by setting the file parameter to NULL.")
bortzmeyer