From: William F. <wsf...@us...> - 2006-11-08 00:52:03
|
Update of /cvsroot/swig/SWIG/Doc/Manual In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv11978/Doc/Manual Modified Files: Java.html Log Message: equals method should have a hashCode method - noticed by Eric Nickell $self special variable for %extend Index: Java.html =================================================================== RCS file: /cvsroot/swig/SWIG/Doc/Manual/Java.html,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** Java.html 4 Nov 2006 22:10:03 -0000 1.75 --- Java.html 8 Nov 2006 00:51:55 -0000 1.76 *************** *** 3450,3454 **** char *toString() { static char tmp[1024]; ! sprintf(tmp,"Vector(%g,%g,%g)", self->x,self->y,self->z); return tmp; } --- 3450,3454 ---- char *toString() { static char tmp[1024]; ! sprintf(tmp,"Vector(%g,%g,%g)", $self->x,$self->y,$self->z); return tmp; } *************** *** 6240,6244 **** Even when the pointers are the same, it will not be possible to know that the two Java classes containing those pointers are actually the same object. It is common in Java to use the <tt>equals()</tt> method to check whether two objects are equivalent. ! An equals method is easily added to all proxy classes. For example: </p> --- 6240,6246 ---- Even when the pointers are the same, it will not be possible to know that the two Java classes containing those pointers are actually the same object. It is common in Java to use the <tt>equals()</tt> method to check whether two objects are equivalent. ! The <tt>equals()</tt> method is usually accompanied by a <tt>hashCode()</tt> method in order to fulfill ! the requirement that the hash code is equal for equal objects. ! Pure Java code methods like these can be easily added: </p> *************** *** 6252,6255 **** --- 6254,6260 ---- return equal; } + public int hashCode() { + return (int)getPointer(); + } %} *************** *** 6498,6502 **** } ~Butler() { ! FireButler(self); } } --- 6503,6507 ---- } ~Butler() { ! FireButler($self); } } |