Click to See Complete Forum and Search --> : array size in c++


abul
July 30th, 2005, 02:24 AM
i am new in c++

but
i hv a project 2 submit.

their condition was to create template class named xyz in c++ dat can perform array operation of unlimited size.

u cn create array larger den physical memeory space.data will be cached into a file n retrived 4m d file when needed.

4 example
class xyz<int>x=new xyz<int>(1000000000);
like dat.

plz do do so send me d code.
i need code.
plz help me.

SuperKoko
July 30th, 2005, 02:31 AM
It is a complex task for a beginner.
So, i suppose you should write a simple (but not optimal) version.
Just use filebuf.
I hope that with your compiler, filebuf::pos_type is 64 bits.

abul
July 30th, 2005, 03:00 AM
#include <iostream.h>
#include <fstream.h>
#include <windows.h>
//namespace std {} // trick BC++ 5.0 which don't use namespace std for iostreams.
//using namespace std;

const int c=10000;


int main()
{
//DWORD t0=GetTickCount(); // get the time
fstream fw;
//SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS);

const long int size=10000000;
fw.open("ss.txt",ios::out);
for(unsigned i=1;i<=size;++i)
fw<<i<<' ';
fw.close();
//DWORD t1=GetTickCount();
//cout<<(t1-t0); // outputs the time (in milliseconds) needed to output!
return 0;
}


tnx 4 ur submission .i hv cnged a little bit.
but by this code i hv to do d following things.
so i hv design it with template n overloading of array[].

i hv 2 randomly access of dat file.to keep speed i hv 2 use memory buffer which will operate as a window 4 d file array.
after writing d code as above i hv 2 test it with

f(x)=sine(x)[for d waveform at .0001 intervals]
f[y]=cos(y)[for d waveform at .0001 intervals]
n den hv to multiply element by element
plz help me by sending code or any other way.