Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34379
| Path | csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: how does one explain this syntax? |
| Date | Mon, 23 May 2016 07:32:36 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 27 |
| Message-ID | <nhuphs$7op$1@dont-email.me> (permalink) |
| References | <nhrhd5$7r6$1@reader1.panix.com> <nhsjoi$hd4$1@dont-email.me> <dqeiopFiq3jU1@mid.individual.net> <nhu3al$36t$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Mon, 23 May 2016 11:29:01 -0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="2d081e2f7155c28005d4472f67c2f43d"; logging-data="7961"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+wRu+z4f3C0fMd/kS+eoLZ" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 |
| In-Reply-To | <nhu3al$36t$1@dont-email.me> |
| Cancel-Lock | sha1:0Bd74YUqXIYq1OfaOyFMvEgix5Q= |
| Xref | csiph.com comp.lang.java.programmer:34379 |
Show key headers only | View raw
On 5/23/2016 1:13 AM, Knute Johnson wrote:
> On 5/22/2016 13:22, Robert Klemme wrote:
>> And why not do this instead?
>>
>> for (final Entry<Integer, String> entry : tmap.entrySet())
>> System.out.printf("key is: %d & value is: %s\n", entry.getKey(),
>> entry.getValue());
>>
>> Note: tmap.get(key) is usually less efficient than fetching the value
>> from an Entry.
>>
>> Kind regards
>>
>> robert
>
> I'll bite, why is it less efficient?
It doesn't need to re-search the map.
Admittedly, Map.Entry is an interface rather than a class, so
it's not a given that the getKey() and getValue() implementations
are one-liners. It seems highly likely, though -- and in the case
of TreeMap, both methods are in fact trivial.
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how does one explain this syntax? ruben safir <ruben@mrbrklyn.com> - 2016-05-22 01:51 -0400
Re: how does one explain this syntax? Martin Gregorie <martin@address-in-sig.invalid> - 2016-05-22 10:05 +0000
Re: how does one explain this syntax? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-22 07:21 -0400
Re: how does one explain this syntax? Popping mad <rainbow@colition.gov> - 2016-05-22 20:21 +0000
Re: how does one explain this syntax? Lars Enderin <lars.enderin@telia.com> - 2016-05-22 22:32 +0200
Re: how does one explain this syntax? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-22 17:32 -0400
Re: how does one explain this syntax? Lew <lewbloch@gmail.com> - 2016-05-23 14:36 -0700
Re: how does one explain this syntax? Lew <lewbloch@gmail.com> - 2016-05-23 14:34 -0700
Re: how does one explain this syntax? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-05-22 08:41 -0700
Re: how does one explain this syntax? Robert Klemme <shortcutter@googlemail.com> - 2016-05-22 22:22 +0200
Re: how does one explain this syntax? Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-05-22 22:13 -0700
Re: how does one explain this syntax? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-23 07:32 -0400
Re: how does one explain this syntax? Robert Klemme <shortcutter@googlemail.com> - 2016-05-23 04:57 -0700
Re: how does one explain this syntax? Popping mad <rainbow@colition.gov> - 2016-05-22 20:23 +0000
Re: how does one explain this syntax? Roedy Green <inquiry@mindprod.com> - 2016-05-30 21:51 -0700
Re: how does one explain this syntax? Roedy Green <inquiry@mindprod.com> - 2016-05-30 21:54 -0700
Re: how does one explain this syntax? Roedy Green <inquiry@mindprod.com> - 2016-05-30 22:00 -0700
Re: how does one explain this syntax? Roedy Green <inquiry@mindprod.com> - 2016-05-30 22:17 -0700
csiph-web