If your input is sorted, you should try just a vector and a binary search (i.e., lower_bound()). This might prove adaquate (it is also O(log n)). Depending on the distribution of your keys and the hash function used, a hash_map might work as well. I think this is tr1::unordered_map in gcc.