Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vector or Hashtable

Status
Not open for further replies.

conor0callaghan

Programmer
Mar 18, 2002
20
0
0
IE
Can anyone tell me which is better and why?
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top