Java - HashMap efficiency

sefie20

Junior Member
Oct 25, 2006
10
0
0
I am implementing a compression algortihm using a HashMap and TreeMap. When I compress a file consisting only of the ASCII character 255, they are both about the same in the time they take to compress. However, when I have a file that has only the 0 character from ASCII (which is just a blank space) the HashMap takes considerably longer, but the TreeMap is about the same. (Note the two files are the exact same size). Thanks a lot
 

you2

Diamond Member
Apr 2, 2002
6,159
1,288
136
Might be the cost of the hash function with no advantage. With the treemap it is comparing the element against other elements in the tree -but no overhead for hash function.