Operation on array - c program, C/C++ Programming

Assignment Help:

Operation on array:

void Array::add( Object& toAdd )

{

    lastElementIndex++;

    while( ptrAt( lastElementIndex ) != ZERO &&

           lastElementIndex <= upperbound

         )

        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 )

        {

        delete ptrAt( atIndex );

        }

 

    setData( atIndex, &toAdd );

}


Related Discussions:- Operation on array - c program

Maths, .Write a program to find the area under the curve y = f(x) between x...

.Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.

Program that controls the lcd display, Objective:  Construct a C program...

Objective:  Construct a C program that controls the LCD display, and is capable of displaying strings.  Add functions to the C program that allows more control over the display.

C language, WHAT IS A C LANGUAGE? C IS A PROGRAMMING?

WHAT IS A C LANGUAGE? C IS A PROGRAMMING?

#compiler design limiting instrutions, Ravi is a newbie to the programming ...

Ravi is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''''''''{'''''''' and end wi

Object tracking project, Identify 2 to 3 existing algorithms commonly used ...

Identify 2 to 3 existing algorithms commonly used for object tracking. Algorithms should be in C or written in MATLAB language. Document these algorithms in flowcharts and run thes

#title., #quGiven the Array class definition in Fig. 11.10-11.11 (pp. 476-4...

#quGiven the Array class definition in Fig. 11.10-11.11 (pp. 476-479) of the textbook, write a new overloaded operator function for the ‘%’ (modulus) operator (i.e., return an arra

#tit, Write a program to find the area under the curve y = f(x) between x =...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Can any constructor throw an exception?, Can any constructor throw an excep...

Can any constructor throw an exception? How to handle error while the constructor fails?

Implement a algorithm to verify if the link list , Implement a Algorithm to...

Implement a Algorithm to verify if the link list is in Ascending order? A: template bool linklist::isAscending() const{ nodeptr ptr = head; while (ptr->_next)

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd