| | |
Allocator doubt in STL Map
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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
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
0
#2 Oct 7th, 2009
u can do that by keeping a counter or as follows:
C++ Syntax (Toggle Plain Text)
class mymap { map<.....> m; int maxsize=5;//say /*if(m.size()<maxsize) then only do more addition to it. Else dont.*/ }
![]() |
Similar Threads
- Cannot write stl's map into a file (C++)
- Deallocating memory used by a STL map (C++)
- 2gb stl map performance (C++)
- Code Snippet: Populate an STL map with two arrays (C++) (C++)
- Code Snippet: Using STL map for elements(Chem.) (C++)
- iterator error of unknown meaning - STL map (C++)
- STL <map> question? (C++)
- sorting stl::map (C++)
Other Threads in the C++ Forum
- Previous Thread: World Fatcs Program
- Next Thread: Help
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





