Version 0.3.3 of HPPC has been released. This release does NOT come
with any code
changes other than cosmetic adjustments in test classes (no changes in
the library code).
It merely marks a switch to Maven as the build platform (full POM is
available) and Maven
Central as the distribution channel for final releases.
0.3.3 artefacts should be visible in Maven Central in about an hour (syncing).
Thanks,
Dawid
This is a known bug/issue that somehow slipped through (there is in
general a problem with generic arrays in Java, they're a pain). I
filed an issue for this here, watch it to get updates:
http://issues.carrot2.org/browse/HPPC-46
Thanks for the info,
Dawid
P.S. Use the project's mailing list so that others know about such
issues, please. Thanks!
On Thu, Feb 17, 2011 at 5:58 AM, dymaxion <spenc...@gmail.com> wrote:
> Dear David,
>
> I stumbled upon your HPPC libraries recently having previously look at
> Trove and Javolution.
> I like the goals of your library and the assertions based checks.
>
> I have come across an issue which is probably a trivial one for you to
> answer, regarding ObjectArrayList
> Whenever I access the buffer directly or call toArray() I get a
> ClassCastException at runtime.
> Instead for buffer access, I have to declare Object[] array, then
> cast each individual element as I iterate over them to avoid the
> problem.
>
> Best regards
> Spencer
>
> eg.
>
> <code>
> ObjectArrayList<MyOwnType> events = new ObjectArrayList<MyOwnType>();
> events.add(.....);
>
> final int size = events.size();
> MyOwnType[] arr1 = events.buffer;
> MyOwnType[] arr2 = events.toArray();
> </code>
>
> Am I doing something silly or is this a known issue with
> workaround....
> I'm using JDK 1.7 (build 1.7.0-ea-b125)
>
>
I advise you to:
1) use the list's getter methods, they do proper casting to the target
type. Casts are cheap and these methods will get inlined anyway.
2) if you really need those arrays, do a cast to Object[] before any
loops (local variable) and then cast to your desired type inside the
loop (again, casts are cheap).
3) if you need T[] array, you will have to create it and
System.arraycopy elements.
Dawid
On Wed, Mar 30, 2011 at 10:15 AM, Spencer Goh <em...@spencergoh.com> wrote:
> Hi David,
>
> I noted the fix for the toArray() method. Thanks.
>
> Is there any workaround for the buffer direct access issue?
>
> I have to do a double cast in order to iterate over an ObjectArrayList's
> internal buffer
> See attached code and test result
>
> Thanks
> Spencer