質問

I want to store a list of (Object, int) in a data structure such that the int field can be easily sorted (ascending or descending). I'm looking at Hashtables and TreeMaps but i'm unsure which, if either, of these are good for this purpose. The priority is the sort speed. Any suggestions?

役に立ちましたか?

解決

Given what you've told us, it's hard to say what'd be best.

If you're concerned with sorting performance alone, a HashTable or TreeMap (actually a red-black binary tree) have great sorting performance, but they're slower than some other data structures when adding (and in TreeMap's case, deleting) items.

You should probably provide more details regarding what you're doing with the data.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top