java - Efficient Map for small ranges of integers -


so have program uses number of hashmaps store low number of integer keys, between 0 , 50, keys represent unique ordinal less 100.

these maps accessed , have done profiling identify have more more efficient datastructure. ideally use akin enummap, these integers small , unique.

restrictions: i'm trying avoid using array many of these maps have handful of possible keys. i'm trying avoid 3rd party libraries. large libraries out, though small libraries, or 1 or 2 classes might alright.

does know of fast map situation?

array should reasonably efficient, given keys <= 100; size of array 400 bytes. don't know entries of map structure, wouldn't reasonably close size.

does matter if maps (as arrays) total 4mb, or 40mb, or whatever? can set jvm heap large.

alternative 2):

  • write own hash-based map class (not implementing collections.map). relatively simple using 'linear probe' in array of cells -- other technique linked-list, (again) large 'direct array' option.

Comments