Hi Wolfgang, On Sun, 2005-11-13 at 20:58 +0100, Wolfgang Baer wrote: > 2005-11-13 Wolfgang Baer <[EMAIL PROTECTED]> > > * javax/print/attribute/HashAttributeSet.java: > Added api docs to class and clarified method documentation. > (toArray): Use iterator from values instead of entries. > (hashCode): Compute hashcode according to specification. > (get): Throw NullPointerException if category is null. > (HashAttributeSet(Attribute[], Class)): Changed to allow > Attribute[] to be null.
Should a HashAttributeSet be thread-safe? In that case you will have to
synchronize on the attributeMap while manipulating it or iterating over
it.
> /**
> - * Returns the hashcode for this object.
> - *
> - * @return the hashcode
> + * Returns the hashcode value. The hashcode value is the sum of all
> hashcodes
> + * of the attributes contained in this set.
> + *
> + * @return The hashcode for this attribute set.
> */
> public int hashCode()
> {
> - return attributeMap.hashCode() + interfaceName.hashCode();
> + int hashcode = 0;
> + Iterator it = attributeMap.values().iterator();
> + while (it.hasNext())
> + hashcode = hashcode + it.next().hashCode();
> +
> + return hashcode;
> }
It would be better to xor (^) the hashCode() values unless this
computation of the hashcode has been specified to use addition of
course. (Note the thread-safety issue above if there is a possibility
that some other thread adds or removes an attribute then this Iterator
could throw ConcurrentModificationException.)
> OK to commit ?
Yes if you can look at/answer the above two observations/questions.
Thanks,
Mark
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Classpath-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/classpath-patches
