Zeljko Trogrlic wrote:
> At 08:52 23.12.99 -0600, you wrote:
> >
> >
> >Zeljko Trogrlic wrote:
> >
> >> Hi,
> >>
> >> I found something suspicious in ConcreteElement. Both registry (Hashtable)
> >> and registryList (Vector) are based on element's hashcode converted to
> >String.
> >>
> >> Is it safe to use hashcodes as unique is because they are not unique for
> >> elements - it's perfectly legal to have two or more different elements with
> >> same hash?
> >>
> >> Why conversion to String?
> >
> >Because hashcodes are stored as primitive integers and it's easier to
> >treat every
> >object key as a string then trying to manipulate it as an object.h
> >
> >-stephan
>
> But my question is still open: is it safe because they are not unique to
> element?
>
They are still unique ever new element still gets a unique hashcodes, and all
strings are turned into StringElements getting a unique object hashcode at that
point.
>
> And isn't it easier and faster to simply wrap int with Integer rather than
> convert it to String?
We do it this way so that we are dealing with a known. We know that all keys are
strings and therefore can make certain assumptions. It's hard to do comparisions
against an unknown.
-stephan
--
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]