Open letter to Ian Collins
- From: jacob navia <jacob@xxxxxxxxxxxx>
- Date: Sun, 27 May 2012 00:22:01 +0200
Hi Ian
In the c++ newsgroup you asked me for an example of the ccl performance
It was something with building a huge list, then sorting it, if I remember correctly...
I have built this example code:
#include <stdlib.h>
#include "containers.h"
#define N 10000000
int main(void)
{
List *L1;
size_t i,d;
long long sum=0,newSum=0;
Iterator *it;
int *pint;
L1 = iList.Create(sizeof(int));
iList.UseHeap(L1,NULL);
for (i=0; i<N;i++) {
d = rand();
sum += d;
iList.Add(L1,&d);
}
iList.Sort(L1);
it = iList.NewIterator(L1);
for (pint = it->GetFirst(it); pint; pint = it->GetNext(it)) {
newSum += *pint;
}
if (sum != newSum)
printf("Failed\n");
else printf("Sum = %lld\n",sum);
iList.Finalize(L1);
}
This creates a list, then fills it with 10 million random integers,
then sorts it and verifies that all the data is still there by
accessing all elements of the list with an iterator.
Can you please send me an equivalent C++program?
Thanks
.
- Follow-Ups:
- Re: Open letter to Ian Collins
- From: Sarah Wren
- Re: Open letter to Ian Collins
- From: io_x
- Re: Open letter to Ian Collins
- From: jacob navia
- Re: Open letter to Ian Collins
- From: Ian Collins
- Re: Open letter to Ian Collins
- From: Ian Collins
- Re: Open letter to Ian Collins
- From: Stephen Sprunk
- Re: Open letter to Ian Collins
- From: MelissA
- Re: Open letter to Ian Collins
- From: Malcolm McLean
- Re: Open letter to Ian Collins
- From: Ike Naar
- Re: Open letter to Ian Collins
- Prev by Date: Re: Merging of string literals guaranteed by C std?
- Next by Date: Re: Open letter to Ian Collins
- Previous by thread: useful macros
- Next by thread: Re: Open letter to Ian Collins
- Index(es):
Relevant Pages
|