commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: [pool] CursorableLinkedList - why does it use a mix of <T>, Object and <E> ?
Date Wed, 13 Oct 2010 12:09:29 GMT
On 13 October 2010 11:36, Simone Tripodi <simone.tripodi@gmail.com> wrote:
> Hi guys,
> and sorry I'm late but there's always the timezone/working time delay :P
>
> The mix with T/E is explained because CursorableLinkedList implements
> List, where there are 2 different signatures of toArray() method, the
> one that uses Object[] and the other one that interests us[1]. That's
> why I didn't use T directly.

I see, so E must be convertible from T.

> The mix with T/Object is my fault, it will be fixed ASAP.
> Agreed that since the interface declares List<E>, we should use E as
> well, it will be fixed ASAP too.
>
> Thanks a lot for reviewing it,

It was Eclipse that pointed out the unchecked casts. I was trying to
understand how to fix them.

But I now see from j.u.List Javadoc that runtime problems are expected
- if you create a List<Integer> and call toArray(new String[0]) you
will get an ArrayStoreException.

> Simo
>
> [1] http://download.oracle.com/javase/6/docs/api/java/util/List.html#toArray(T[])
>
> http://people.apache.org/~simonetripodi/
> http://www.99soft.org/
>
>
>
> On Wed, Oct 13, 2010 at 2:54 AM, sebb <sebbaz@gmail.com> wrote:
>> On 13 October 2010 01:15, Paul Benedict <pbenedict@apache.org> wrote:
>>> The whole <E> convention comes from java.util where there are
>>> "elements" of a collection.
>>
>> Yes, I know.
>>
>>> I don't like to mix things. I think type T
>>> would be find everywhere unless you have multiple types and need a
>>> memorable letter.
>>
>> As far as I can tell, the collection only supports a single type,
>> similar to List<E>, and one would not expect to see other types used
>> in such a List class.
>>
>> But I could be wrong which is why I was asking.
>>
>> Since j.u.List uses <E>, I think it would make sense use <E> here as
well.
>>
>>> On Tue, Oct 12, 2010 at 6:21 PM, sebb <sebbaz@gmail.com> wrote:
>>>> CursorableLinkedList is based on the type T, and removeFirst() returns
>>>> T, yet getFirst() returns Object.
>>>>
>>>> Also, toArray() returns Object[] or E[].
>>>>
>>>> Not sure I follow why there is this mixture?
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message