문제

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