Life is never simple....I started applying the patch, but hit some problems

By comparison with the JDK, the method asList(Object[]) is on Arrays. Thus I
have applied the patch to ArrayUtils in [lang] instead of [collections].

toMap(Object[]) fitted fine.

When I looked at asMap(Object[]) I discovered certain problems that we
hadn't considered:
- the array doesn't behave like a Map when looking up keys because its not
hashed
- what happens if someone changes the underlying array, to put an illegal
object type or null into the array
- the implementation didn't correctly handle the values(), entrySet() or
keySet() methods which should provide a view onto the real data (which would
actually be tricky to implement).

So, there is either a lot more work on asMap(), or we say that toMap covers
most cases anyway.

Stephen

----- Original Message -----
From: "Moritz Petersen" <[EMAIL PROTECTED]>
To: "Commons Dev" <[EMAIL PROTECTED]>
Sent: Sunday, October 13, 2002 2:34 PM
Subject: [collections] [PATCH] MapUtil


> The patch contains:
>
> MapUtil#toMap(Object[]) - converts the array to a Map
> MapUtil#asMap(Object[]) - wraps an ArrayMap around the array
> MapUtil.ArrayMap        - inner class for #asMap(Object[])
>
> TestMapUtil#testToMap()
> TestMapUtil#testAsMap()
>
>
> Patch was applied:
>
> diff -u -r1.13 MapUtils.java
> diff -u -r1.2 TestMapUtils.java
>
>
>
> -Moritz.
>
>


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to