avatar
Simple question# Java - 爪哇娇娃
g*y
1
What's the most efficient data structure in Java to express:
key -> {key1:value1, key2:value2, ... keyN:valueN}
HashMap is one way. Since I need no operation other than
getter/setter, class is kind of heavy. Anything lighter?
avatar
g*g
2
Class is not heavy, just go ahead, a clean structure is way
better than minimal performance gain.

than

【在 g**********y 的大作中提到】
: What's the most efficient data structure in Java to express:
: key -> {key1:value1, key2:value2, ... keyN:valueN}
: HashMap is one way. Since I need no operation other than
: getter/setter, class is kind of heavy. Anything lighter?

avatar
A*o
3
maybe op was doing memory tuning? ^_^

【在 g*****g 的大作中提到】
: Class is not heavy, just go ahead, a clean structure is way
: better than minimal performance gain.
:
: than

avatar
m*t
4

You'd be suprised how much more memory efficient a Bean is than a hashmap.
8-)
Unless the keys in OP are dynamic, I'd define a bean class as bug suggested
and do it The Right Way(tm).

【在 A**o 的大作中提到】
: maybe op was doing memory tuning? ^_^
avatar
g*g
5
Usually when we talk about performance, it's about data structure and
algorithm, the efficiency of single unit access, is far less important.
c << logN and we don't care about it until we have to.

suggested

【在 m******t 的大作中提到】
:
: You'd be suprised how much more memory efficient a Bean is than a hashmap.
: 8-)
: Unless the keys in OP are dynamic, I'd define a bean class as bug suggested
: and do it The Right Way(tm).

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。