Re: How to use hash map to store values of function.
Roedy Green wrote:
On Tue, 11 Mar 2008 10:00:07 -0400, Lew <lew@lewscanon.com> wrote,
quoted or indirectly quoted someone who said :
private final transient int hash;
if you make your hash transient you have to write some code to
recompute it on reconstitution.
See http://mindprod.com/jgloss/serialization.html#TRANSIENT
If you are going to serialise these beasts, which I don't think would
be likely, you need to say implements Serializable.
Correct on both counts, though I disagree that serialization is not a likely
need in the example. The Key class as presented is a prime candidate for
serialization. Its whole presentation was intended to provide a basis for
"full-blown entity classes" as one would find with Hibernate or JPA generally.
It is natural, and helpful for some systems like Apache OpenJPA, to make
entity classes serializable.
I declared the instance variables transient without making the class
Serializable so I could make the point in that post about how one would go
about serializing it. You'll note the comments at the bottom that were hints
about where one would go past the Key class as presented. Obviously in a
Usenet post one can only hope to outline the groundwork, not lay out a
complete working application.
--
Lew