question on data structure

C

c++novice

Any suggestions
which stl data structure to use if
--i need to lookup names indexed by integer idnumbers assigned
contiguously from 0 to 10000.
--if the names were indexed by SSN#?

does hashtable fit here, indexed from 1 to 10000, but before storing
into a hash table, i should order them, and then can perform binary
search on it. i guess this is most efficient or is there any other
way.

for indexed by SSn#, can have a hash().

Thanks for any help:)
 
B

Buster

c++novice said:
Any suggestions
which stl data structure to use if
--i need to lookup names indexed by integer idnumbers assigned
contiguously from 0 to 10000.

std::deque said:
--if the names were indexed by SSN#?

By whom, sorry?
does hashtable fit here, indexed from 1 to 10000, but before storing
into a hash table, i should order them, and then can perform binary
search on it.

Any ordering would be destroyed anyway.
i guess this is most efficient or is there any other way.
?

for indexed by SSn#, can have a hash().

??
 
J

John Harrison

c++novice said:
Any suggestions
which stl data structure to use if
--i need to lookup names indexed by integer idnumbers assigned
contiguously from 0 to 10000.

a vector
--if the names were indexed by SSN#?

a map
does hashtable fit here, indexed from 1 to 10000,

not really, the key word is 'contiguously', you can't get more efficient
than a vector size 10000.

[snip]
for indexed by SSn#, can have a hash().

hash would work, except its not yet an official STL data structure.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,353
Latest member
RogerDoger

Latest Threads

Top