开发者

How to use Collection API? [closed]

开发者_StackOverflow It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I have a packet having fields :

Root Level : CHOICE

Level 1 : SET

Level 2 : SEQUENCE , CHOICE

Note : CHOICE :- You can have one available fields.

SET :- Fields can be in any order.

SEQUENCE : Fields are in specific order.

Assume each field has a unique id for specific level.

I want to read and then put in one one Collection API.

Can anybody suggest how to use MAP, SET or List in an efficient way?


SET > Set (Tutorial)
SEQUENCE > List (Tutorial)
CHOICE doesn't really have a mapping in the Collection API, but you could use AtomicReference.


Your ability to use a structure in an efficient way is entirely dependent upon how you wish to access the data. If you want to be able to find a specific item according to a key, use a HashMap. If you want to be able to have an arbitrary list of items, use ArrayList. If you wish to be able to both access a specific item according to a key and be able to iterate all items like a list, use LinkedHashMap.

Though from what you're describing about a set of CHOICE, it seems to me you're talking about an enumerator. Enumerators are essentially static sets, and unless you intend on modifying your choices dynamically, I would suggest you use this rather than a Set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜