home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
bc45
/
clobss.pak
/
ARRAY.CPO
< prev
next >
Wrap
Text File
|
1997-07-23
|
2KB
|
51 lines
/*------------------------------------------------------------------------*/
/* */
/* ARRAY.CPP */
/* */
/* Copyright Borland International 1991, 1993 */
/* All Rights Reserved */
/* */
/*------------------------------------------------------------------------*/
#if !defined( __CHECKS_H )
#include <checks.h>
#endif // CHECKS_H
#if !defined( __ARRAY_H )
#include "classlib\obsolete\array.h"
#endif // __ARRAY_H
void Array::add( Object& toAdd )
{
lastElementIndex++;
while( lastElementIndex <= upperbound &&
ptrAt( lastElementIndex ) != ZERO
)
lastElementIndex++;
if( lastElementIndex > upperbound )
reallocate( lastElementIndex - lowerbound + 1 );
setData( lastElementIndex, &toAdd );
itemsInContainer++;
CHECK( itemsInContainer > 0 );
}
void Array::addAt( Object& toAdd, int atIndex )
{
PRECONDITION( atIndex >= lowerbound );
if( atIndex > upperbound )
reallocate( atIndex - lowerbound + 1 );
if( ptrAt( atIndex ) != ZERO )
{
if( ownsElements() )
delete ptrAt( atIndex );
itemsInContainer--;
}
setData( atIndex, &toAdd );
itemsInContainer++;
CHECK( itemsInContainer > 0 );
}