Allocator doubt in STL Map

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

Join Date: Dec 2007
Posts: 18
Reputation: Aashath is an unknown quantity at this point 
Solved Threads: 5
Aashath's Avatar
Aashath Aashath is offline Offline
Newbie Poster

Allocator doubt in STL Map

 
0
  #1
Oct 6th, 2009
HI guys

I am using STL map in one of my project . I want to limit my size of my STL map size based on the use input , how do i do it .

For Example : if the user types in 5 as input then my program should be able to insert only 5 elements into my map not more that that . Hodo i do such allocation. Thanks
"The most important single aspect of software development is to be clear about what you are trying to build." - Bjarne Stroustrup
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 352
Reputation: dkalita will become famous soon enough dkalita will become famous soon enough 
Solved Threads: 53
dkalita's Avatar
dkalita dkalita is offline Offline
Posting Whiz
 
0
  #2
Oct 7th, 2009
u can do that by keeping a counter or as follows:
  1. class mymap
  2. {
  3. map<.....> m;
  4. int maxsize=5;//say
  5.  
  6. /*if(m.size()<maxsize) then only do more addition to it. Else dont.*/
  7. }
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC