ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Memoization in Java Using Dynamic Proxy Classes
Subject:   Methods as Keys
Date:   2003-08-22 08:35:05
From:   crazybob
Response to: Methods as Keys

You can store SoftReferences to the cached values and remove a key when it's value gets collected (using a ReferenceQueue).


One more note, arrays as method arguments. Rather than using Arrays.asList(), I use a class I wrote called ArrayObject (http://crazybob.org/downloads/ArrayObject.java). Basically, it just implements equals() and hashCode() for arrays. It also compares nested arrays, which is why it works for array arguments.