C++, difficulties in choosing STL 's containers

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2006
Posts: 3
Reputation: bencwai is an unknown quantity at this point 
Solved Threads: 0
bencwai bencwai is offline Offline
Newbie Poster

C++, difficulties in choosing STL 's containers

 
0
  #1
Nov 30th, 2006
I have to redesign a bookshop programme which allow user to make order of books.
This programme is originally using vector to implement.Now i have to decide either use deque or hash_map for the programme or i would better keep using vector??

In fact, I just know these three kinds of containers in STL.Are there any other choices in STL???


Thank you so much~
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 14
Reputation: nattylife is an unknown quantity at this point 
Solved Threads: 3
nattylife nattylife is offline Offline
Newbie Poster

Re: C++, difficulties in choosing STL 's containers

 
0
  #2
Nov 30th, 2006
hash-map(or hash tables) are usually used for getting retrieval of records in O(n) time... something you'd see in a database design. vector is probably the quickest and simplest way to go:
- its dynamically re-sizable
- you can access any element in linear time.
as your customer orders book, its as simple as pushing back the the book onto your order vector.
my vote says staty with the vector. but if you dont/ cant use a vector, theres always a linked list (doubly linked list) too.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC