Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #39597
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Compare generics (that are numbers) |
| Date | 2020-07-29 21:32 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <rft7um$17k2$1@gioia.aioe.org> (permalink) |
| References | <87k0ym73id.fsf@munus.decebal.nl> <rfscpe$doa$1@dont-email.me> <87ft9a6u35.fsf@munus.decebal.nl> <rfsgek$jm4$1@gioia.aioe.org> <87bljy6qu3.fsf@munus.decebal.nl> |
On 7/29/2020 3:53 PM, Cecil Westerhof wrote:
> Arne Vajhøj <arne@vajhoej.dk> writes:
>> On 7/29/2020 2:42 PM, Cecil Westerhof wrote:
>>> Eric Sosman <esosman@comcast-dot-net.invalid> writes:
>>>> On 7/29/2020 11:19 AM, Cecil Westerhof wrote:
>>>>> I have a class that starts with:
>>>>> abstract class CalcValuesGeneric<E> {
>>>>>
>>>>> E will be Integer, int, Float or float. (For now, but always a Number.)
>>>>> What is the best way to determine which of the two is lower?
>>>>
>>>> Aside: How can you get `<E>' to be `<int>' or `<float>'? Is that
>>>> something new? I'm still on Java 8, but the JLS for 14 says "Seq<int>
>>>> is illegal, as primitive types cannot be type arguments." (4.5)
>>>
>>> You are completely right, I was not thinking straight. :'-(
>>
>> Probably a common miswording.
>>
>> class CalcValuesGeneric<E> {
>> void something(E v)
>> ...
>> cvg.something(x);
>>
>> E can be Integer or Float but not int or float.
>>
>> But x can be int and float as well due to auto boxing.
>
> But I do not want auto boxing. The particular case I am working with
> shows that int can take 40% less CPU and memory when using Integer.
>
> I will find another way. Thanks.
Well - code that handle objects does require objects.
:-)
But if this is performance critical then why not just drop the
generic stuff and write specific code for the types?
Arne
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Compare generics (that are numbers) Cecil Westerhof <Cecil@decebal.nl> - 2020-07-29 17:19 +0200
Re: Compare generics (that are numbers) Arne Vajhøj <arne@vajhoej.dk> - 2020-07-29 13:21 -0400
Re: Compare generics (that are numbers) Arne Vajhøj <arne@vajhoej.dk> - 2020-07-29 13:27 -0400
Re: Compare generics (that are numbers) Eric Sosman <esosman@comcast-dot-net.invalid> - 2020-07-29 13:48 -0400
Re: Compare generics (that are numbers) Cecil Westerhof <Cecil@decebal.nl> - 2020-07-29 20:42 +0200
Re: Compare generics (that are numbers) Arne Vajhøj <arne@vajhoej.dk> - 2020-07-29 14:50 -0400
Re: Compare generics (that are numbers) Cecil Westerhof <Cecil@decebal.nl> - 2020-07-29 21:53 +0200
Re: Compare generics (that are numbers) Arne Vajhøj <arne@vajhoej.dk> - 2020-07-29 21:32 -0400
Re: Compare generics (that are numbers) Cecil Westerhof <Cecil@decebal.nl> - 2020-07-30 11:33 +0200
Re: Compare generics (that are numbers) Eric Sosman <esosman@comcast-dot-net.invalid> - 2020-07-30 09:03 -0400
Re: Compare generics (that are numbers) Cecil Westerhof <Cecil@decebal.nl> - 2020-07-30 17:00 +0200
Re: Compare generics (that are numbers) Arne Vajhøj <arne@vajhoej.dk> - 2020-07-30 09:21 -0400
Re: Compare generics (that are numbers) Silvio <silvio@internet.com> - 2020-07-30 08:51 +0200
Re: Compare generics (that are numbers) Cecil Westerhof <Cecil@decebal.nl> - 2020-07-30 11:36 +0200
Re: Compare generics (that are numbers) Marcel Mueller <news.5.maazl@spamgourmet.org> - 2020-07-29 20:59 +0200
csiph-web