2006/7/26, Alex Blewitt <[EMAIL PROTECTED]>:
There are other approaches that could be used instead of this. For
example, the value of the hashCode could be cached in a private
variable and then invalidated when any setValue() methods are called.
One could even imagine a superclass performing this caching work:

public abstract class HashCode {
 private boolean valid = false;
 private int hash;
 public final int hashCode() {
   if (!valid) {
     hash = recalculateHashCode();
     valid = true;
   }
   return hash;
 }
 protected abstract int recalculateHash();
 protected void invalidate() { valid = false; }
}

Of course, you could use the HashCode object to calculate the hash value :-)
Unfortunately
1. class can has temporary private fields (see BasicStroke.java)
2. class can has final fields which take part in hash code calculation
(see EllipticCurve.java)

--
Denis M. Kishenko
Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to