Mar 11, 2004 #1 conor0callaghan Programmer Mar 18, 2002 20 IE Can anyone tell me which is better and why?
Mar 11, 2004 #2 PerFnurt Programmer Feb 25, 2003 972 SE See http://www.codeguru.com/Cpp/Cpp/algorithms/hash/article.php/c5131/ /Per "It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure." Upvote 0 Downvote
See http://www.codeguru.com/Cpp/Cpp/algorithms/hash/article.php/c5131/ /Per "It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."
Mar 11, 2004 #3 uolj Programmer Jul 2, 2003 529 GB Both. If your data can be stored based on keys consisting of a contiguous set of integers, then a vector is better than a hash table. If your data must be stored based on keys that are non-integer or are not contiguous then maybe a hash table is better than a vector. There are thousands of other situations where one might be better than the other. P.S. A vector is a hash table with integer keys where Hash(x) = x. Upvote 0 Downvote
Both. If your data can be stored based on keys consisting of a contiguous set of integers, then a vector is better than a hash table. If your data must be stored based on keys that are non-integer or are not contiguous then maybe a hash table is better than a vector. There are thousands of other situations where one might be better than the other. P.S. A vector is a hash table with integer keys where Hash(x) = x.