size limit in list-sort-unique or am I messed up 
Author Message
 size limit in list-sort-unique or am I messed up

I was surprised to see my list of strings get truncated when I had a large
number of items in the list.

With 20,000 items in the list I could sort and make sure they were unique.
But when the number of items in the list went up to 40,000 the number of
items was truncated.

Am I hitting a maximum size of one of the data types? If so is there an easy
work around?

Thanks,
LM

#include "stdafx.h"

#pragma warning(disable:4786) // for STL implementation
#include <list>
#include <string>

using namespace std;

typedef list<string, allocator<string> > LIST_STR;

// comment out this next line to see the problem
//#define WORKS_OK

#ifdef WORKS_OK
 #define SIZE 10000
#else
 #define SIZE 20000
#endif

int main(int argc, char* argv[])
{
 LIST_STR    list;
 LIST_STR::iterator  it;
 int      i;
 char     c[256];

 // fill the list
 for (i=0; i < SIZE; i++)
 {
  list.push_back(itoa(i, c, 10));
 }

 printf("list size = %d\n", list.size());

 // add some duplicates to the list
 for (i=0; i < SIZE; i++)
 {
  list.push_back(itoa(i, c, 10));
 }

 printf("list size after adding duplicates= %d\n", list.size());

 list.sort();
 printf("list size after sort= %d\n", list.size());

 list.unique();
 printf("list size after unique= %d\n", list.size());

 return 0;

Quote:
}

//output
//list size = 20000
//list size after adding duplicates= 40000
//list size after sort= 7232
file://list size after unique= 7232


Fri, 19 Sep 2003 18:49:28 GMT  
 size limit in list-sort-unique or am I messed up

Quote:
> I was surprised to see my list of strings get truncated when I had a large
> number of items in the list.

> With 20,000 items in the list I could sort and make sure they were unique.
> But when the number of items in the list went up to 40,000 the number of
> items was truncated.

> Am I hitting a maximum size of one of the data types? If so is there an easy
> work around?

You're hitting a known bug in list<T>::sort. For an easy fix, see:

http://www.dinkumware.com/vc_fixes.html

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com



Fri, 19 Sep 2003 23:23:13 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. list:: unique and sort wouldn't work

2. Size limit for Columns in List Controls?

3. List files...and sort by name, date, size

4. Sort order messed up in dialogs

5. Sorting array with non-unique key and qsort

6. Child processes in Mess-DOS, and/or reducing code size

7. Fonts size messes up my GUI

8. How can I limit the size of inner panels inside a CSplitterWnd

9. ATL Server: Limiting the size of a request

10. C1067 : compile limit: debug information module size exceeded

11. array size limit and the standard

12. Array size limit w/ VC++

 

 
Powered by phpBB® Forum Software