PDA

View Full Version : STL Container Size Limit Report



kryton9
23-12-2011, 07:40
I wrote this little test program to find the size limits of some of the Standard Template Library Containers. I would like to see what differences, if any, and which situations machine to machine, OS to OS or both.
It is a console app. You might need to scroll up to see the whole output. It will give your results first and then print my results for reference.

The code listing is just for reference. The attachment has the executable console app.


#include <iostream>
#include <stdlib.h>
#include <vector>
#include <list>
#include <map>

using namespace std;

int kvs = 1073741823;
int kvi = 1073741823;
int kls = 357913941;
int kli = 357913941;
int km = 178956970;

int main()
{
vector<string> vs;
vector<int> vi;

list<string> ls;
list<int> li;

map<int,string> m;

cout << endl << " Container Limits" << endl << endl ;

cout << " Your Results: "<< endl << endl;
cout << " Vector of strings: "<< vs.max_size() << endl;
cout << " Vector of integers: "<< vi.max_size() << endl << endl;

cout << " List of strings: "<< ls.max_size() << endl;
cout << " List of integers: "<< li.max_size() << endl << endl;

cout << "Map of ints and strings: "<< m.max_size() << endl << endl;
cout << "==================================================" << endl;
cout << " Kent's Results: "<< endl << endl;
cout << " Vector of strings: "<< kvs << endl;
cout << " Vector of integers: "<< kvi << endl << endl;

cout << " List of strings: "<< kls << endl;
cout << " List of integers: "<< kli << endl << endl;

cout << "Map of ints and strings: "<< km << endl << endl;
system("pause");
return 0;
}

jcfuller
23-12-2011, 12:41
Kent,


I am a novice c++ programmer so I use the latest Bcx. No {}; needed


Using MinGWTDM compiler on Win7 64.
Compiled as 32bit and 64bit app
32bit matches yours. Not sure on the 64bit results


James


$CPP
$NOMAIN
'32bit
$ONEXIT "GCTD.BAT $FILE$ -m32"
'64bit
'$ONEXIT "GCTD.BAT $FILE$ -m64"
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
#include<vector>
#include<list>
#include<map>
Dim Raw As int kvs = 1073741823,kvi = 1073741823,kls = 357913941,kli = 357913941,km = 178956970
Function main() As Integer

vector<string> vs
vector<int> vi

list<string> ls
list<int> li

map<int,string> m

cout << endl << " Container Limits" << endl << endl

cout << " Your Results: "<< endl << endl
cout << " Vector of strings: "<< vs.max_size() << endl
cout << " Vector of integers: "<< vi.max_size() << endl << endl

cout << " List of strings: "<< ls.max_size() << endl
cout << " List of integers: "<< li.max_size() << endl << endl

cout << "Map of ints and strings: "<< m.max_size() << endl << endl
cout << "==================================================" << endl
cout << " Kent's Results: "<< endl << endl
cout << " Vector of strings: "<< kvs << endl
cout << " Vector of integers: "<< kvi << endl << endl

cout << " List of strings: "<< kls << endl
cout << " List of integers: "<< kli << endl << endl

cout << "Map of ints and strings: "<< km << endl << endl


system("pause")
End Function

kryton9
24-12-2011, 00:55
Thanks James. I am sorry I forgot to mention the attachment had an executable. I just listed the code, for reference, as to what was in the executable.
You pointed out a major flaw in my test, not testing for 32 bit and 64 bit. Thanks for both listings. At least I know now that it can change.