[Home]History of PEZ/HelpRequest

Robo Home | Changes | Preferences | AllPages


Revision 6 . . July 24, 2004 22:37 EST by PEZ
Revision 5 . . July 24, 2004 21:16 EST by Kawigi
  

Difference (from prior major revision) (no other diffs)

Changed: 15c15,17
An interesting note about using Java maps if you're not using strings as keys - If you use a HashMap?, you won't be able to dependably retrieve objects unless the class of the key overrides hashCode() (and probably equals(), like Pulsar said), and if you use a TreeMap?, you must implement the Comparable interface in the key class for it to work correctly. Quite a few of the standard libraries already do these things (like String), but it's something to make sure about. -- Kawigi
An interesting note about using Java maps if you're not using strings as keys - If you use a HashMap?, you won't be able to dependably retrieve objects unless the class of the key overrides hashCode() (and probably equals(), like Pulsar said), and if you use a TreeMap?, you must implement the Comparable interface in the key class for it to work correctly. Quite a few of the standard libraries already do these things (like String), but it's something to make sure about. -- Kawigi

Yeah, that's why I use String objects as keys. Though implementing hashCode() and equals() isn't too much of a bother. But String objects work as good as anything else for the purposes I use them for here, -- PEZ

Robo Home | Changes | Preferences | AllPages
Search: