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

Command-line arguments, Command-line arguments are passed into programs usi...

Command-line arguments are passed into programs using the arguments of main(). Here's a quick example, for a program called by typing "progname file.txt 1 2.7": #include #incl

Need solution for simple beginner level c program, search words from a pass...

search words from a passage and return snippets in html format..

C language, in a program for what purpose print f and scan f is used

in a program for what purpose print f and scan f is used

Assignment, write a simple c++ program to that use the value to add five nu...

write a simple c++ program to that use the value to add five number .your program should prompt the user to enter these five numbers one after the other

Doubt!, find the greater of the two variables, without using conditional lo...

find the greater of the two variables, without using conditional loops or ternary operators?

Fill an array of randomly generated integers, The task consists of two part...

The task consists of two parts which are both preferably implemented in one source file. Towards the end of this document you will find a code skeleton that you must assume. Start

Advanced, how to create a shopping cart

how to create a shopping cart

First line starts with T, Byteland county is very famous for luminous jewe...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Opp, what is oops

what is oops

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