//////////////////////////////////////
// START of File: C0_DYARR.CPP
//////////////////////////////////////

//===================================================================
//
// COPYRIGHT NOTICE:  This code is protected by Copyright!
//
// Copyright (c) 1994, 1995, 1996, 1997 by DPC Technology.
// All rights reserved. 
//
// See files "cf_copyr.h" and "cf_licen.h" for details of 
// copyright and license specifications, and contact information.
//
//===================================================================

//#include    <stdafx.h>
#include	<cf_api/bf_defs.h>
#include    <cf_api/c0_dyarr.hpp> 
            // relative to the IDE's (global) include path: ~/cfrz

cf_DyArr
    ::cf_DyArr() 
{
    this->pvArray = NULL;
    resize (16);
}


cf_DyArr
    ::cf_DyArr(int iInitSize)
{
    this -> pvArray = NULL;
    resize (iInitSize);
}


cf_DyArr
    ::~cf_DyArr() 
{
    delete [] this -> pvArray;
}


void*&
cf_DyArr
    ::operator[] (int iIndex)
{
    while (iIndex >= this -> iSize)
    {
        resize (2 * (this -> iSize));
    }

    return (this -> pvArray[iIndex]);
}


void
cf_DyArr
    ::growBy (int iIncrement)
{
    resize (this -> iSize + iIncrement);
}


void
cf_DyArr
    ::resize(int iNewSize)
{
    void**      pvNewArray;


    pvNewArray = new void*[iNewSize];
    if (this -> pvArray != NULL)
    {
        for (int i = 0; i < this -> iSize; i++)
        {
            pvNewArray[i] = this -> pvArray[i];
        }
        delete [] this -> pvArray;
    }

    this -> pvArray = pvNewArray;
    this -> iSize = iNewSize;
}


//
// End of cf_DyArr Pseudo-Implementation/Mapping.
//

//////////////////////////////////////
// END of File: C0_DYARR.CPP
//////////////////////////////////////




