hello all,
Can anyone tell me how to create & use Java Maps in my C++
code...
I've used java.util.Vector, it works fine.
I work on a Sun Fire V440 machine.
regards,
gautam.
AndrewTK - 27 Mar 2006 14:24 GMT
C doesn't use Java. Java may use C but I dont know how to do that.
You'd be best off describing what a Map is to the C community and
taking it from there...
Chris Uppal - 27 Mar 2006 14:30 GMT
> Can anyone tell me how to create & use Java Maps in my C++
> code...
> I've used java.util.Vector, it works fine.
java.util.Map is an interface, not a class. You can create instances of
classes that implement that interface (such as java.util.HashMap and
java.util.TreeMap). It's just the same in C++/JNI as it is in Java (just more
verbose).
-- chris
john m - 27 Mar 2006 15:19 GMT
use the JNI methods provided in C++ to create an object that implements
the Map interface. remember the map interface is just a interface...not
a concrete class.
don't forget c++ has its own containers like this, vector and map etc
etc...do you really need to do this?..just #include <list> and or
#include <map> and you're sorted..excuse the pun
> hello all,
>
[quoted text clipped - 5 lines]
> regards,
> gautam.
Roedy Green - 27 Mar 2006 20:07 GMT
> Can anyone tell me how to create & use Java Maps in my C++
>code...
> I've used java.util.Vector, it works fine.
> I work on a Sun Fire V440 machine.
If you have done vector you need exactly the same sort of thinking to
do ArrayList or HashMap. Perhaps the only extra piece you need it how
to create a reference to an Interface rather than a Class so you can
do Map x in C++.
It looks as if you treat interfaces as if they were full classes. See
page 48 of the Sheng Liang book. See
http://mindprod.com/jgloss/jni.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
gautam.chavan@gmail.com - 28 Mar 2006 05:54 GMT
hello all,
Thanks a lot.
It worked.
I had given a wrong signature to the "put" method of HashMap.
Warm Regards,
gautam.