TJHugeArray
This is a simple sparse array templateclass.  The array can be indexed
by any unsigned long value.  The implementation given is limited in
scope but can easily be enhanced ( exceptions, etc. )

The template class must provide a default constructor.  This constuctor is
used to initialize the array elements.

Constructors:

TJHugeArray( const T& ZeroValue )
The ZeroValue is the default value for uninitialized array elements.  This
object is returned when a const TJHugeArray is indexed at an element that
has not been specified through the non-const operator[]

TJHugeArray()
The default return value for unitialized array elements is the default
constructor of the template class.

const T& operator[]( const unsigned long index ) const
Returns the element at the given position.  If the position has not been
initialized then this returns the ZeroValue.

T& operator[]( const unsigned long index )
Returns the reference to the element at the given position.  If the position
has not been initialized then a new element is created at the given
position.


Technical Notes:
This is not a replacement for standard C style arrays.  It can be used as
a dynamic array ( sized during run-time ) effectively.  I have successfully
created an array of 2 million double values, adding one at a time, on
a win95 system with 16M of memory.  This class is designed to be used where
few elements ( relative to the desired total size ) are actually specified
with the remaining elements being the ZeroValue.  Care should be taken to
access the const version of the [] operator when element inquiry is
desired, ie.

TJHugeArray<double> TheArray;
/* Initialize any array elements you wish here */

double Sum = FindSum( TheArray );

...
...
...

double FindSum( const TJHugeArray<double>& SumArray )
{
    double localSum = 0.0;

    for( unsigned long i = 0 ; i < 40000000L ; i++ )
    {
        localSum += SumArray[i];    
    }

    return localSum;
}

Even better would be to add this functionality to the class or to a derived
class.  This could be done much more efficiently there.


Misc:
This is a shareware class that may be freely distributed.  The class may
be used for personal and non-commercial purposes without charge.
Commercial use requires the permission of the author.

Questions, comments, suggestions... write to wortcook@aol.com
