如果interview需要用C++ hashtable,咋办呢?用什么lib? 另外,map and hashtable 的区别。 如果知道map和hashtable中只有一个element,用户要print这个element,那个快?why?
v*7
2 楼
你说的是C++中的map 和 JAVA中的hashtable的区别吗?不知道你问什么。不过如果是 的话,C++中的map internally is implemented by a tree which is sorted. But hashtable in JAVA internally is implemented by a hashing function, So the time for retrieving key-value pair is different. For map in C++, it is O(log n), in hashtable it can be considered O(1). And in Java, hashtable is synchronized.